Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re^9: perl dancer route template hashref pass complex json file to server issue (the reverse)by tye (Sage) |
on Jul 28, 2016 at 22:27 UTC ( [id://1168768]=note: print w/replies, xml ) | Need Help?? |
You have it backward. You don't need to disable some template filter. You need to create and then enable an appropriate template filter. Your templated javascript contains lines like:
If the value provided for 'passtoserver' was "Don't do this", then the javascript generated by your template would be:
That is a syntax error. So you need to change your template to contain lines more like:
or, perhaps even better:
where the "| js_str" tells the template to properly escape any characters that need to be escaped in order to be included verbatim inside of a javascript string literal (and, in the second case, also adds the enclosing quote marks). And, no, Template::Toolkit doesn't come with a pre-built js_str filter so you'll have to create that as well. Your problem case is due to the \ character not being escaped for similar reasons. So your template produces javascript code like:
And, in javascript, '\"' is the same value as '"'. - tye
In Section
Seekers of Perl Wisdom
|
|