Pystache without escaping (unescaped)
To prevent escaping use triple braces {{{var}}}
To prevent escaping, use triple braces, {{{URL}}}
instead of double braces {{URL}}
>>> pystache.render('The URL {{{URL}}}', {'URL': 'http://google.com?a=3&b=3'})
u'The URL http://google.com?a=3&b=3'
I've tested this on the most recent release as of today, version 0.5.4
Mustache Documentation
Since Pystache is a Mustache implementation in Python, you can use Mustache's documentation as pointers.
All variables are HTML escaped by default. If you want to return unescaped HTML, use the triple mustache: {{{name}}}.
source: https://mustache.github.io/mustache.5.html
A long time ago they've got such suggestion.
There is auxillary escape
option of Renderer
class initializer. This option accepts function that operates on strings. Default is cgi.escape(s, quote=True)
.
So when you write:
import pystache
rend = pystache.Rendered(escape=lambda s: s)
rend.render(your_obj)
you've got unascaped values without tripple braces in template.
See docs on Rendered
class