I'm using the following basic introduction example from here: https://github.com/janl/mustache.js/
I'm using the following code:
var tmp_view = {
title: "Joe",
calc: function(){
return 2+5;
} };
var tmp_output = Mustache.render("{{title}} spends {{calc}}", tmp_view);
However, in my browser all I'm getting is:
var tmp_output = Mustache.render(" spends ", tmp_view);
Which renders "spends"
Edit: I think I have a better understanding of why this is happening but I'm not sure how to resolve it.
I am using spark for my server and have the following
get("/foobar", (req, res) -> new ModelAndView("",
"foobar.mustache"), new MustacheTemplateEngine());
In my .mustache file I make a JSON request and inside that JSON request is where I want to render another template.
You should try to redefine your delimiter in mustache.
Based on mustache documentation :
Set Delimiter tags start with an equals sign and change the tag delimiters from {{ and }} to custom strings.
Consider the following contrived example:
- {{ default_tags }} {{=<% %>=}}
- <% erb_style_tags %> <%={{ }}=%>
- {{ default_tags_again }} Here we have a list with three items. The first item uses the default tag style, the second uses ERB style as defined by the Set Delimiter tag, and the third returns to the default style after yet another Set Delimiter declaration.
Call {{=<% %>=}}
to change {{ }}
by <% %>