In my Mustache template, I would like to comment a couple of lines, but I am unable to do it. I am still getting the comments displayed in HTML. What is the correct way to add comments? Anyone can help me to sort this out please?
here is my code:
<script type="text/html" id="inspector-splitViewBase">
<div class="inspector-split-view-container flex-1 flex-fill flex-down">
<header class='split-view-inspector-header'>
<div class="view-title">Source Assets</div>
{{!-- <div class="actions"> commented
<span class="label">Actions</span>
<span class="gear"></span>
</div> --}} - comment is not working
</header>
<div class='search-container'>
<span class="search-icon"></span>
<input type="text" value="" class="inspector-search" />
</div>
<div class="source-assets-list-container flex-1"></div>
<footer></footer>
</div>
</script>
you can easily comment it out via: {{! TODO: Determine why this code fragment does not work {{#foo}}{{bar}}{{/foo}} !}}
A mustache template is a string that contains any number of mustache tags. Tags are indicated by the double mustaches that surround them. {{person}} is a tag, as is {{#person}} . In both examples we refer to person as the tag's key.
Mustache is a logic-less templating system. It permits you to use pre-written text files with placeholders that will be replaced at run-time with values particular to a given request.
Mustache is a logic-less template syntax. It can be used for HTML, config files, source code - anything. It works by expanding tags in a template using values provided in a hash or object. We call it "logic-less" because there are no if statements, else clauses, or for loops.
Mustache documentation suggests to use following for comments:
Comments begin with a bang and are ignored. The following template:
<h1>Today{{! ignore me }}.</h1>
Will render as follows:
<h1>Today.</h1>
Comments may contain newlines.
I assume that in your case you had to use
{{! blah }}
Instead of
{{!-- blah --}}
You are trying to comment on mustache template that also has html in it, so you actually have to add mustache comment where the mustache code is and html comment where the html code is.
.
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