Skip to content

Instantly share code, notes, and snippets.

@givanse
Last active May 3, 2017 22:08
Show Gist options
  • Save givanse/73681f4bd3463d96d730ee47ac4bd52c to your computer and use it in GitHub Desktop.
Save givanse/73681f4bd3463d96d730ee47ac4bd52c to your computer and use it in GitHub Desktop.
build DOM elements with a helper
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export function buildDomNode(params/*, hash*/) {
const text = params[0];
const div = document.createElement('DIV');
div.style.backgroundColor = '#0000ff';
div.style.color = '#fff';
div.innerText = text;
return div;
}
export default Ember.Helper.helper(buildDomNode);
{{build-dom-node "hello world"}}
{{log (build-dom-node "hello world")}}
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment