pystache
pystache copied to clipboard
Escape double braces
I'd prefer to use the double braces format for my variables, however, I'd like pystache to ignore certain cases, such as in this legitimate javscript snippet:
<script>!function(d,s,id){{var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){{js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}}}(document, 'script', 'twitter-wjs');</script>
What should I be doing here? True, I can just add a space between the {{, but surely Pystache supports this in some way?
According to this Stack Overflow question, there’s no built-in way to escape an instance of {{. If you can’t work around it—for example, by adding a space between the braces in your example—you can change the delimiters temporarily or you can add a “braces” value to your context that will output {{ when you input {{braces}}.