Escape double braces {{ … }} in Mustache template. (templating a template in NodeJS)

后端 未结 6 2245
萌比男神i
萌比男神i 2020-12-05 02:28

I\'m trying to template a template, like below:

{{{
{
  \"name\" : \"{{name}}\",
  \"description\" : \"{{description}}\"
}
}}}

{{{debug this}}}
6条回答
  •  醉话见心
    2020-12-05 03:02

    You can also assign Mustache.tags = ["[[", "]]"]; before your template compilation.

    http://jsfiddle.net/fhwe4o8k/1/

    e.g.

        $(function () {
            Mustache.tags = ["[[", "]]"];
            var template = $('#test').html();
            Mustache.parse(template);
            var rendered = Mustache.render(template, {test: "Chris"});
            $('#content-placeholder').html(rendered);
        });
    

提交回复
热议问题