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}}:
评论
您可以使用以下语法为模板添加注释.
Run Code Online (Sandbox Code Playgroud){{! This is a comment }}如果您希望它们最终出现在输出中,您也可以使用真正的HTML注释.
Run Code Online (Sandbox Code Playgroud)<div> {{! This comment will not end up in the output }} <!-- This comment will show up in the output --> </div>
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上,所以我想帮助未来的读者)
| 归档时间: |
|
| 查看次数: |
10740 次 |
| 最近记录: |