September 24, 2012
I was looking for Handlebars partials (or templates that i could embed) that I can render like partials in Rails:
render :partial => "partial_name"
You can either register a partial for a small inline code snippet:
/* partials.js */
Handlebars.registerPartial("time",
'<time datetime="{{created_at}}">{{created_at}}</time>'
);
/* file.handlebars */
some text created at: {{> time}}
or the more convenient way: create a new template file (eg. time.handlebars) and include it with Ember.Handlebars helper „template“, like so:
/* time.handlebars */
<time datetime="{{created_at}}">{{created_at}}</time>
/* file.handlebars */
some text created at: {{template "path/to/file/time"}}
That’s it, pay attention to the right path otherwise Ember will not find the template (just see the console for the error message)!