How to add comments into a mustache template?

3gwebtrain picture 3gwebtrain · Oct 22, 2013 · Viewed 11.6k times · Source

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>

Answer

AbstractVoid picture AbstractVoid · Jun 5, 2015

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 --}}