Tag: Handlebars

Ember makes use of the wonderful Handlebars templates. These templates, in order to be performant, must be precompiled. Based on the Ember docs, it’s not abundantly clear how this is to happen. Here’s a solution that works well.

Have you ever wanted to do something special every nth time through a Handlebars loop? The built-in {{#each}} will loop through your items just fine. It lacks a few features. For one, you don’t have access to the loop index, though you can find it. Without the index and simple comparisons like modulus, length of the array, and equals, you’ll be creating your own Handlebars helpers. Here’s an example of one.

HandlebarsJs is a great Javascript templating engine. It’s pretty much Mustache templates on steriods – or Rogaine or something like that. Well, there’s a great for loop, but it’d be cool if it had a loop index built in. It doesn’t have one as of the current version (1.0.0.beta.6). But, we can make an easy helper.

If you have to store your text strings for internationalization (i18n) on the server, that’s one thing. But, if you can store them in Javascript, you might think about using RequireJs and its i18n plugin, because it makes it nice and easy.