Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add comments into a mustache template?

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>
like image 337
3gwebtrain Avatar asked Oct 22 '13 12:10

3gwebtrain


People also ask

How to comment code in mustache file?

you can easily comment it out via: {{! TODO: Determine why this code fragment does not work {{#foo}}{{bar}}{{/foo}} !}}

What is in mustache template?

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.

How does a mustache file work?

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.

What is mustache syntax?

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.


2 Answers

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 --}}
like image 138
AbstractVoid Avatar answered Sep 17 '22 15:09

AbstractVoid


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.

.

like image 27
4 revs Avatar answered Sep 18 '22 15:09

4 revs