How to use comments in Handlebar templates?

前端 未结 4 479
谎友^
谎友^ 2021-01-30 10:15

I am using Handlebar.js as my templating engine. Now I want to comment out some of the blocks in my handlebar templates. But then I realized that Handlebar doesn\'t ignore the e

4条回答
  •  不思量自难忘°
    2021-01-30 10:27

    Use this way in your handlebar template file.

    {{!-- only output author name if an author exists --}} {{#if author}}

    {{author.firstName}} {{author.lastName}}

    {{/if}}

    The comments will not be in the resulting output. If you'd like the comments to show up, then use HTML comments.

    {{! This comment will not be in the output }}

    refer this link to

提交回复
热议问题