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 } // 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? 回答1: it's just like this: <span> {{#like}} Like <!-- If {like: true}