Created
August 16, 2018 16:21
-
-
Save semanticpixel/f2a6d0429670d3fe589b4e857b57117a to your computer and use it in GitHub Desktop.
experiment-helper
This file contains hidden or 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 default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
imageURL: 'img/test.png', | |
styles: { | |
height: '300px', | |
'background-image': 'url(img/test.png)', | |
} | |
}); |
This file contains hidden or 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'; | |
import { htmlSafe } from '@ember/string'; | |
const GLUE = ':'; | |
const SEPARATOR = ';'; | |
function joinStyles(styles) { | |
return Object.keys(styles) | |
.map(style => `${style}${GLUE}${styles[style]}`) | |
.join(SEPARATOR); | |
} | |
export function myHelper(params, hash) { | |
const styles = joinStyles(hash); | |
return htmlSafe(styles); | |
} | |
export default Ember.Helper.helper(myHelper); |
This file contains hidden or 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'; | |
const GLUE = '='; | |
const SEPARATOR = ' '; | |
function joinParams(params) { | |
return Object.keys(params) | |
.map(param => `${param}${GLUE}${params[param]}`) | |
} | |
export function myOtherHelper(params) { | |
const obj = params[0]; | |
console.log(joinParams(obj)) | |
return joinParams(obj); | |
} | |
export default Ember.Helper.helper(myOtherHelper); |
This file contains hidden or 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
{ | |
"version": "0.15.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.2.2", | |
"ember-template-compiler": "3.2.2", | |
"ember-testing": "3.2.2" | |
}, | |
"addons": { | |
"ember-data": "3.2.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment