How to handle an IF STATEMENT in a Mustache template?

前端 未结 4 1540
一个人的身影
一个人的身影 2020-12-13 23:34

I\'m using mustache. I\'m generating a list of notifications. A notification JSON object looks like:

[{\"id\":1364,\"read\":true,\"author_id\":30,\"author_na         


        
4条回答
  •  被撕碎了的回忆
    2020-12-14 00:12

    In general, you use the # syntax:

    {{#a_boolean}}
      I only show up if the boolean was true.
    {{/a_boolean}}
    

    The goal is to move as much logic as possible out of the template (which makes sense).

提交回复
热议问题