You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A template containing an apostrophe causes problems with client side templating. The browser shows an error which Firebug shows as "JSON.parse: bad escaped character", and in Chrome is simply "Uncaught SyntaxError: Unexpected token ILLEGAL".
Test code. When you click "Click here", it ought to replace "mustache thing" with "client thing", but instead the error above is shown on page load, leading to "to_html is undefined" if you click on Click Here.
#{mustache.template 'thing'}
this is a {{template}} with an a'postrophe
#{/mustache.template}
<span id="content">#{mustache.print "thing", context: [template: "mustache thing"] /}</span>
<span id="click">Click here</span>
<script>
$(function() {
$("#click").click(function() {
var html = PlayMustache.to_html("thing", { "template": "client thing" })
$("#content").empty()
$("#content").append(html)
})
})
</script>
The text was updated successfully, but these errors were encountered:
A template containing an apostrophe causes problems with client side templating. The browser shows an error which Firebug shows as "JSON.parse: bad escaped character", and in Chrome is simply "Uncaught SyntaxError: Unexpected token ILLEGAL".
The problem is that the #{mustache.meta} tag uses JavaExtensions.escapeJavascript() when inserting the template into JSON. This escapes single quotes, but the JSON specification does not allow single quotes to be escaped (see http://stackoverflow.com/questions/2275359/jquery-single-quote-in-json-response)
Test code. When you click "Click here", it ought to replace "mustache thing" with "client thing", but instead the error above is shown on page load, leading to "to_html is undefined" if you click on Click Here.
The text was updated successfully, but these errors were encountered: