Created
May 11, 2014 18:44
-
-
Save samuraisam/dbf582b8bc41de445358 to your computer and use it in GitHub Desktop.
Dynamic component
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
var elementMap = { | |
'char': 'dyn-text-field' | |
}; | |
var DynamicFormField = Ember.Component.extend({ | |
template: Ember.computed('entry.field', function(key, value) { | |
var kind = this.get('entry.field.kind'); | |
var helperName = elementMap[kind] || 'dyn-text-field'; | |
var tmpl = '{{' + helperName + ' entry=entry}}'; | |
return Ember.Handlebars.compile(tmpl); | |
}) | |
}); | |
export default DynamicFormField; | |
// called like this: {{dyn-form-field entry=subentry}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment