defunkt / pystache

Mustache in Python
http://mustache.github.com/
MIT License
1.31k stars 308 forks source link

Escape double braces #175

Open polybuildr opened 9 years ago

polybuildr commented 9 years ago

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?

bdesham commented 8 years ago

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}}.