Feature request: customizable escape function
redsun82 opened this issue · 4 comments
It' be nice to be able to pass an escaping function to accommodate instantiating templates for non-html languages. Pystache supports this via an escape
parameter. As a use case, I use mustache templates in C++ code generation, where escaping &
breaks everything. I can explicitly unescape things in the templates, but it's just easier to pass escape=lambda x: x
. JSON string escaping comes to mind as another use case.
@shahargl not really, I filed this when I was considering porting my code from pystache to chevron, but this was a blocker, so I just kept pystache
@redsun82 Got you. Why did you consider moving? I see pystache last commit is 10 years ago, do you have any problem with it?
@shahargl pystache works reasonably ok, but it's not up to date with the mustache spec. In particular I was interested in parents with overrideable blocks, which would simplify a bit my templates, but are not supported by pystache.
Obviously a workaround for this specific issue to use chevron is to consistently use {{{...}}}
in the templates instead of {{...}}
, but that adds a bit of visual noise to the template files.