In this section you will learn how to reuse Mustache templates in Handlebars.java
A partial is a template that can be included into other template. Syntax is as follow:
<h1>{{title}}</h1>
<span>Powered by Handlebars.java</span>
{{> header}}
<p>Home page</p>
{{> footer}}
<h1>Title</h1>
<p>Home page</p>
<span>Powered by Handlebars.java</span>
Partials begin with a greater than sign, like {{> box}}.
Partials are rendered at runtime (as opposed to compile time), so recursive partials are possible. Just avoid infinite loops.
Template inheritance can be done with block/partial syntax
.
{{#block "header"}}
<h1>Title</h1>
{{/block}}
{{#block "content"}}
{{/block}}
{{#block "footer" }}
<span>Powered by Handlebars.java</span>
{{/block}}
{{#partial "content" }}
<p>Home page</p>
{{/partial}}
{{> base}}
<h1>Title</h1>
<p>Home page</p>
<span>Powered by Handlebars.java</span>
Thank you, for reading the Handlebars.java blog.