Express by Examples
Hogan template engine
In contrarry of Jade, Hogan is a Mustache style template engine {{ variable }}.
Sending simple variable:
<p>variable: {{ var }} </p>
Iterate array:
var vdata=
{
title: 'Fruits',
fruit_arr: ['apple', 'orange', 'banana']
}
//res.send(dump(vdata));
res.render('examples/11hogan_array', vdata);
<ul>
{{#fruit_arr}}
<li>{{.}}</li>
{{/fruit_arr}}
</ul>
Iterate array with objects:
var vdata=
{
title: 'Fruits',
fruit_arr:
[
{name:'apple', quantity: 100},
{name:'orange', quantity: 200},
{name:'banana', quantity: 350}
]
}
res.render('examples/12hogan_array_obj', vdata);
<ul>
{{#fruit_arr}}
<li>{{name}} - {{quantity}}</li>
{{/fruit_arr}}
</ul>