Mustache Javascript: How To Handle With Boolean Values
I have a javascript object obj and the value of the key can be true or false. This value is passed to mustache template. // javascript object obj = { like: true // or false }
Solution 1:
it's just like this:
<span>
{{#like}}
Like <!-- If {like: true} --->
{{/like}}
{{^like}}
Unlike <!-- If {like: false} --->
{{/like}}
</span>
Solution 2:
Just use a section and an inverted section:
{{#like}}
<span>
Like <!-- If {like: true} --->
</span>
{{/like}}
{{^like}}
<span>
Unlike <!-- If {like: false} --->
</span>
{{/like}}
Post a Comment for "Mustache Javascript: How To Handle With Boolean Values"