Skip to content

Instantly share code, notes, and snippets.

@nojacko nojacko/README.md
Last active Nov 10, 2016

Embed
What would you like to do?
Dynamically render HTMLBars.

How to use

{{dynamic-template source=htmlbarsTemplateStingHere}}
import Ember from 'ember';
export default Ember.Component.extend({});
{{#if subLayout}}
{{dynamic-template-render layout=subLayout}}
{{/if}}
import Ember from 'ember';
export default Ember.Component.extend({
source: '',
subLayout: null,
didInsertElement() {
Ember.run.scheduleOnce('afterRender', this, 'updateTemplate');
},
updateTemplate() {
this.set('subLayout', null);
Ember.run.scheduleOnce('afterRender', this, function() {
this.set('subLayout', Ember.HTMLBars.compile(this.get('source')));
});
},
observerSource: Ember.observer('source', function() { this.updateTemplate(); }),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.