Render template from component and get DOM element


#1

Hi, I’m trying to do something like this:

//app/components/my-component.js
var template = Ember.getTemplate ('my-template');
template.setParameter ('name', 'Julian');
var dom = template.getDOM (); 

//app/templates/my-template.hbs
<h1>{{name}}</h1>

Is this posible?


#2

I think there is more context needed.

Within a component it is no problem.

You can do something like:

// app/components/my-component.js
MyComponent = Ember.Component.extend({
     name: 'Julian',
     becomeFocused: function() {
        var componentsDomElement = this.$();
        // doStuff
    }.on('didInsertElement')
});

//app/templates/components/my-component.hbs
<div class="some-class">
    name: {{name}} <--- should automaticly resovle to Julian
</div>