Handlebars identifiers may be any unicode character except for the following which will fail validation:
Whitespace ! " # % & ' ( ) * + , . / ; < = > @ [ \ ] ^ ` { | } ~
The words true
, false
, null
, and undefined
are only allowed in the first part of a path expression.
Use segment-literal bracket [ ] notation to reference a field name that includes one of the above values:
{{#each articles.[10].[#comments]}}
You can't include a closing bracket ]
in a path-literal, but all other characters may be used.
You can also use JavaScript-styled strings and "double quotations" vs. [bracket pairs].
{{!-- wrong: {{array.0.item}} --}} correct: array.[0].item: {{array.[0].item}} {{!-- wrong: {{array.[0].item-class}} --}} correct: array.[0].[item-class]: {{array.[0].[item-class]}} {{!-- wrong: {{./true}}--}} correct: ./[true]: {{./[true]}}
For more information, see the Handlebars.js documentation on literal segments.
Comments
Please sign in to leave a comment.