I am using HandlebarsJS for my templating needs.
I have a nested object:
{
"amount": {
"preTax": 15.99,
"tax": 0.0,
"currencyCode": "USD",
"total": 15.99
}
}
And I have the following template:
{{#amount}}
<div>PreTax is {{preTax}}. Tax is {{tax}}. Currency Code is {{currencyCode}} and total is {{total}}</div>
{{/amount}}
Is this the best practice for accessing nested properties within a property? Like declaring the block for the data property or I need to use with?
Like so:
{{#with amount}}
<div>PreTax is {{preTax}}. Tax is {{tax}}. Currency Code is {{currencyCode}} and total is {{total}}</div>
{{/with}}
I know that both approaches work. And in mustache-js I always used the former approach.