任何人都可以告訴我如何在emberjs句柄模板中包含註釋代碼?如何在emberjs腳本句柄中進行評論?
<script id="restaurantDetail" data-template-name='restaurantDetail' type="text/x-handlebars">
//Commented code goes here
</script>
任何人都可以告訴我如何在emberjs句柄模板中包含註釋代碼?如何在emberjs腳本句柄中進行評論?
<script id="restaurantDetail" data-template-name='restaurantDetail' type="text/x-handlebars">
//Commented code goes here
</script>
從github page的長相,你想{{! comment text here}}
:
評論
你可以用下面的語法添加註釋到您的模板。
{{! This is a comment }}
如果您希望它們在輸出中結束,您還可以使用真實的html註釋。
<div> {{! This comment will not end up in the output }} <!-- This comment will show up in the output --> </div>
我推薦使用{{!-- 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 --}}
(我知道這是一個老問題,但這個答案當搜索ember模板評論時,首先出現在Google上,所以我想幫助未來的讀者)
這絕對是要走的路,在學習Ember的過程中幫助我很多(只要確保你不會亂扔你的模板,並註釋掉代碼:)) – 2016-11-12 20:17:28
這可能是在後續版本中添加的?正如接受的答案是從2012年起,這是從2015年起 – user2831723 2018-02-16 09:18:00
此外,如果您使用真正的html註釋並希望包含變量,請務必使用[unbound helper](http://docs.emberjs.com/#doc=Handlebars.helpers&method=.unbound&src=false)'<! - Item {{unbound itemId}} - >' – 2012-06-01 13:23:12
是否需要註釋他們自己的{{}}容器還是允許內聯,如{{name!this是App.controller.content.name}}? – iX3 2012-09-18 13:30:09