javascript - Mustache js output mustache js code -


i'm trying make mustache js output content without parsing variables. example:

{{block.type}}-{{block.id}}-label-{{element.id}} 

i want parse block, , why giving following json:

{ block: { type: 'news', id: 23 } } 

the end result should be

news-23-label-{{element.id}} 

but instead is

news-23-label- 

how should make not parse part of code? i'm new in mustache js , not find in documentation (comments understood, if , foreach understood, not find this).

would workaround you? click fiddle.

html:

<div id="output"></div>  <script type="text/html" id="test1">     {{block.type}}-{{block.id}}-label-{{block.elid}} </script> 

js:

var output = $("#output"),     template = $("#test1").html(),     data = '{ "block": { "type": "news", "id": 23, "elid": "{{element.id}}" } }',     html = mustache.render(template, json.parse(data));  output.append(html); 

output:

news-23-label-{{element.id}} 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -