The way data is passed in partials in salesforce/handlebars-php isn't the same as it is over at handlebars.js
Inspired by this issue
In this gist, we have a dataset of names that we want to display on a page. We are using a partial to format the display of the names to avoid writing repetitive code.
[
"names"=>[
"boys" => [
["name"=>"Liam"],
["name"=>"Noah"],
["name"=>"William"]
],
"girls" => [
["name"=>"Olivia"],
["name"=>"Emma"],
["name"=>"Ava"]
]
]
]
Pay attention to the use of the this
in name_list.partial.
Output of this gist is:
<p>Boys Names</p>
<ul>
<li>Liam</li>
<li>Noah</li>
<li>William</li>
</ul>
<p>Girls Names</p>
<ul>
<li>Olivia</li>
<li>Emma</li>
<li>Ava</li>
</ul>