Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
93
rated 0 times [  95] [ 2]  / answers: 1 / hits: 21486  / 13 Years ago, thu, february 2, 2012, 12:00:00

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
}


// template



<span>
{{ like }}
</span>


Now I would like having the result of the rendering in this way:



<span>
Like <!-- If {like: true} --->
</span>

<span>
Unlike <!-- If {like: false} --->
</span>


What is the best way to make it in mustache template?


More From » mustache

 Answers
14

it's just like this:



<span>
{{#like}}
Like <!-- If {like: true} --->
{{/like}}
{{^like}}
Unlike <!-- If {like: false} --->
{{/like}}
</span>

[#87675] Wednesday, February 1, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
havenbilliec

Total Points: 324
Total Questions: 106
Total Answers: 94

Location: Pitcairn Islands
Member since Fri, Oct 15, 2021
3 Years ago
;