Handlebars学习(5)- 模板注释{{!--}}或{{!}}

可以再Handlebars代码中使用注释。

  <div class="entry">
    {{!-- only output this author names if an author exists --}}
    {{#if author}}
      <h1>{{firstName}} {{lastName}}</h1>
    {{/if}}
  </div>

注释不会在结果中输出。如果你想要注释输出,可以使用html注释,这样注释就会被输出。

  <div class="entry">
    {{! This comment will not be in the output }}
    <!-- This comment will be in the output -->
  </div>

任何注释都必须包含结束标记}},而其它的Handlebars标记应该使用{{!-- --}}语法。

posted @ 2014-12-18 17:24  South Wind  Views(754)  Comments(0)    收藏  举报