Search code examples
node.jsexpressmustache

Mustache - Check Boolean object property within object array


Actually I'm using mustache-express, and I know that I can use conditionals like: {{^isFalse}} and {{#isTrue}}, this stuff is working fine, but my problem is:

I send an object array to template and list their properties with {{prop1}}{{prop2}}

My object has a Boolean property that is only true for the first object, and I need to grab another property from this object and set as audio element source, which I couldn't do, despite this snippet. Probably I'm missing something... But this is what I tried with no success:

Access the Boolean property directly (as he did):

{{#myBoolean}}
<audio hidden src="{{myPath}}"></audio>
{{/myBoolean}}

Access within the array call, as I'm doing with my list:

{{#myArray}}
{{#myBoolean}}
<audio hidden src="{{myPath}}"></audio>
{{/myBoolean}}
{{/myArray}}

Is there any way I can do this without having to create a separate object?


Solution

  • The answer was:

    {{#myArray.0}}
    <audio hidden src="{{myPath}}"></audio>
    {{/myArray.0}}