Moe-js v0.3


Partials let you embed the contents of another template inside this template.

For example, this will invoke the "UserDetails" template, passing the current model as the model for the template.

{{> "UserDetails" }}

Note that unlike Mustache/Handlebars, the name of the partial template must be quoted because it's a JavaScript expression - which also means you can dynamically synthesize the name of the partial to invoke:

{{> "UserDetails_" + model.role }}

When invoking a partial from within an {{#each}} block, the current loop item is passed as the partial's model. In this example, the current user would be passed as the model to the partial template:

{{#each u in model.Users}}
{{> "UserDetails" }}

You can also, pass an explicit object to the partial template:

{{> "UserDetails", model.user}}

Subscribe for more like this. No spam, just fun tech stuff :)

Or, find me on Twitter: @toptensoftware.