如何在emberjs脚本把手中做评论?

Kap*_*arg 27 sproutcore handlebars.js ember.js

谁能告诉我如何在emberjs把手模板中包含注释代码?

  <script id="restaurantDetail" data-template-name='restaurantDetail' type="text/x-handlebars">
//Commented code goes here
</script>
Run Code Online (Sandbox Code Playgroud)

D.S*_*ley 38

github页面的外观,你想要{{! comment text here}}:

评论

您可以使用以下语法为模板添加注释.

{{! This is a comment }}
Run Code Online (Sandbox Code Playgroud)

如果您希望它们最终出现在输出中,您也可以使用真正的HTML注释.

<div>
    {{! This comment will not end up in the output }}
    <!-- This comment will show up in the output -->
</div>
Run Code Online (Sandbox Code Playgroud)


Ift*_*tah 19

我建议使用,{{!-- comment here --}}因为此注释语法可以包含新行,也可以包含}}注释,例如:

Bad comments:
    {{! badly commented {{if somecondition "red" "blue" }} }}  
    {{! badly multiline comments
        another line  }}  

Comment that works:
    {{!-- this is commented correctly {{if somecondition "red" "blue" }} --}}
    {{!-- correct multiline comments
        another line  --}}  
Run Code Online (Sandbox Code Playgroud)

(我知道这是一个老问题,但在搜索ember模板评论时,这个答案首先出现在Google上,所以我想帮助未来的读者)