I have a template that I’d like to capture its output as a string that I can store on a model. For example:
I’m using Ember Rails, so I don’t have the script tag
in app/assets/javascripts/templates/person_as_xml.handlebars
<person>
<name>{{name}}</name>
<children>
{{#each children}}
<kid><name>{{name}}</name></kid>
{{/each}}
</children>
</person>
Then I want to, perhaps in an action:
actions: {
save: function(person){
person.xml_representation = Handlebars.render_template("person_as_xml.handlebars", person);
person.save();
}
}
Obviouisly I made up the syntax for render_template, but that’s essentially what I want to do. How can I do it?