jquery - Mustache Render Ignoring all {{ }} -


i'm using following basic introduction example here: https://github.com/janl/mustache.js/

i'm using following code:

  var tmp_view = {     title: "joe",     calc: function(){       return 2+5;     }   };    var tmp_output = mustache.render("{{title}} spends {{calc}}", tmp_view); 

however, in browser i'm getting is:

var tmp_output = mustache.render(" spends ", tmp_view); 

which renders "spends"

edit: think have better understanding of why happening i'm not sure how resolve it.

i using spark server , have following

get("/foobar", (req, res) -> new modelandview("",         "foobar.mustache"), new mustachetemplateengine()); 

in .mustache file make json request , inside json request want render template.

you should try redefine delimiter in mustache.

based on mustache documentation :

set delimiter tags start equals sign , change tag delimiters {{ , }} custom strings.

consider following contrived example:

  • {{ default_tags }} {{=<% %>=}}
  • <% erb_style_tags %> <%={{ }}=%>
  • {{ default_tags_again }} here have list 3 items. first item uses default tag style, second uses erb style defined set delimiter tag, , third returns default style after yet set delimiter declaration.

call {{=<% %>=}}to change {{ }}by <% %>


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -