(or the SUNRISE solution)
Java
PHP
Node
Templates
Web tests
Apps
Twirl
Twig
Swig
Java
PHP
Node
Template
Web tests
Apps
HBS
Frontend
Backend
.
.
HTML
.
.
TWIRL
changes
changes
Frontend
Backend
.
.
HBS
changes
Backend
Frontend
.
.
TWIRL
Backend
Frontend
.
.
HBS
v2.0
+ others
{
"cart":{
"hasItems":true,
"lineItems":[
{
"name":"milk",
"quantity":5
},
{
"name":"eggs",
"quantity":12
}
]
}
}
{{#cart}}
{{#hasItems}}
<ul>
{{#lineItems}}
<li>{{name}} - {{quantity}}</li>
{{/lineItems}}
</ul>
{{/hasItems}}
{{^hasItems}}
<p>Your cart is empty!</p>
{{/hasItems}}
{{/cart}}
<ul>
<li>milk - 5</li>
<li>eggs - 12</li>
</ul>
Nested paths
{{user.age}}, {{../user}}
Customised behaviour with helpers
Useful built-in helpers
{{#if}}, {{#else}}, {{#each}}...
Pass arguments to helpers/partials
@data variables
@index, @first, @last...
{
"cart":{
"lineItems":[
{
"name":"milk",
"quantity":5
},
{
"name":"eggs",
"quantity":12
}
]
}
}
{{#if cart.lineItems}}
<ul>
{{#each cart.lineItems}}
<li>{{name}} - {{quantity}}</li>
{{/each}}
</ul>
{{else}}
<p>Your cart is empty!</p>
{{/if}}
<ul>
<li>milk - 5</li>
<li>eggs - 12</li>
</ul>
Ports of Handlebars.js in other languages
Java, Scala, Ruby, PHP...
Even more functionalities
Built-in helpers, @data vars...
Value resolvers using reflection
Usually custom helpers are not portable
Java uses Rhino to enable them
There might be inconsistencies among languages
CSS
JS
IMG
CSS
JS
IMG
CSS
JS
IMG