Can anybody tell me how to include commented code in emberjs handlebars templates?
<script id="restaurantDetail" data-template-name='restaurantDetail' type="text/x-handlebars"> //Commented code goes here </script>
If you'd like the comments to show up just use HTML comments, and they will be output. Any comments that must contain }} or other handlebars tokens should use the {{! -- --}} syntax.
An HBS file is a template file created by Handlebars, a web template system. It contains a template written in HTML code and embedded with Handlebars expressions. An HBS file performs the same function as a . HANDLEBARS file.
From the looks of the github page, you want {{! comment text here}}
:
Comments
You can add comments to your templates with the following syntax.
{{! This is a comment }}
You can also use real html comments if you want them to end up in the output.
<div> {{! This comment will not end up in the output }} <!-- This comment will show up in the output --> </div>
I recommend using {{!-- comment here --}}
because this comment syntax can contain new lines and also }}
inside the comment, for example:
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 --}}
(I know this is an old question, but this answer appears first on Google when searching for ember template comments, so I wanted to help future readers)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With