Skip to content

Instantly share code, notes, and snippets.

@HenryVonfire
Last active November 17, 2015 10:51
Show Gist options
  • Save HenryVonfire/8b5abaaddd4f44683d53 to your computer and use it in GitHub Desktop.
Save HenryVonfire/8b5abaaddd4f44683d53 to your computer and use it in GitHub Desktop.
Custom style inline without warnings
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
Console should not display any warnings, as both style bindings are SafeString
{{my-style}}
<br>
<br>
import Ember from 'ember';
export default Ember.Component.extend({
attributeBindings: [
'bgStyle:style'
],
bgColor: '#222222',
bgStyle: Ember.computed('bgColor',function() {
return (`background-color:${this.get('bgColor')};text-align:center; font-size:20px;`).htmlSafe();
}),
textColor: '#ffffff',
textStyle: Ember.computed('textColor',function() {
return (`color:${this.get('textColor')}`).htmlSafe();
})
});
<p style={{textStyle}}>
hello
</p>
{
"version": "0.4.11",
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.9/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.11/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.9/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment