Search code examples
javascriptpythonknockout.jspyramidmako

Pyramid, Javascript: I get HTML numbers instead of quotes


I return the dict as follows from pyramid view:

return {'details': json.dumps(details)}

From a mako template, I access the variable as:

var a = ${details};

But Javascript throws Uncaught SyntaxError: Unexpected token & because the quotes used in details are converted into HTML numbers(").

How can I resolve this?


Solution

  • Based on the documentation of the filtering in Mako:

    You need use the n filter to disable all the filters declared in the <%page> tag as well as in default_filters (which contains the HTML escaping filter h by default)

    So you need to write

    var a = ${details | n};