Created
February 29, 2016 11:21
-
-
Save nire0510/b09e971ea10ddf04e8fa to your computer and use it in GitHub Desktop.
Ember helper: safe binding of inline style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export function inlineStyle(params, hash) { | |
let strInnerStyle = ''; | |
for (let key in hash) { | |
if (hash.hasOwnProperty(key)) { | |
hash[key] = (key === 'background-image') ? `url(${hash[key]})` : `${hash[key]}`; | |
strInnerStyle += `${key}: ${hash[key]}; `; | |
} | |
} | |
return new Ember.Handlebars.SafeString(strInnerStyle); | |
} | |
export default Ember.Helper.helper(inlineStyle); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment