If I have a static list of cached users within my application under App.Users
, there will likely be various instances where I need to display the list of users. Typically, I would just pass the list along with the context to the template.
var tmpl = Handlebars.templates['TemplateName'];
var html = tmpl({
model: model,
users: App.Users
});
However, this method involves setting up connections in both the template and the javascript code. Ideally, I would prefer to handle this directly in the template so that it doesn't have to be remembered in the scripts. For example...
{{#each {{users}}}}
<li> ... </li>
{{/each}}
In this scenario, the users
helper function simply returns App.Users
. Wouldn't that be convenient?
Unfortunately, this code snippet does not actually compile. Are there any other solutions available?