I have an object that I am rendering in JSRender. Almost everything works except for the evaluation of a nested object I have.
"traits": {
"admin": true,
"editor": true,
"writer": true
}
It is part of a larger object that I am sending to the template.
I have been trying to get JSRender to display an icon next to a name based on the traits.
{{if traits.admin}}
<div class="icon iconadmin"></div>
{{/if}}
{{if traits.editor}}
<div class="icon iconeditor"></div>
{{/if}}
{{if traits.writer}}
<div class='icon iconwriter'></div>
{{/if}}
I have tried using an {{if}} {{else }} structure as well as a {{for}} loop but in each case the template only renders the first icon the user has in their traits object.
If I switch the code around it will successfully display, for instance, the editor icon if I move the test for editor to be evaluated first.
Is the problem that I am using an object?
I can get the code to work using {{props}}
At that point it will iterate over the properties in the
traitskey and then evaluate them.I am going to enter this as a bug.