有谁能告诉我如何在Ember.js的Handlebars模板中包含注释代码?
<script id="restaurantDetail" data-template-name='restaurantDetail' type="text/x-handlebars">
//Commented code goes here
</script>
有谁能告诉我如何在Ember.js的Handlebars模板中包含注释代码?
<script id="restaurantDetail" data-template-name='restaurantDetail' type="text/x-handlebars">
//Commented code goes here
</script>
从 github 页面来看,您想要使用{{! 在这里添加注释文本}}
:
注释
您可以使用以下语法向模板中添加注释。
{{! This is a comment }}
如果您希望HTML注释最终出现在输出结果中,您也可以使用真实的HTML注释。
<div>
{{! This comment will not end up in the output }}
<!-- This comment will show up in the output -->
</div>
我建议使用{{!-- 在此添加注释 --}}
,因为这种注释语法可以包含换行符并且在注释中也可以使用}}
,例如:
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 --}}
(我知道这是一个老问题,但当在谷歌搜索Ember模板注释时,这个答案会首先出现,所以我想帮助未来的读者)
<!-- Item {{unbound itemId}} -->
。 - Ilia Choly