Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Make escape function configurable #86

Prinzhorn opened this Issue · 4 comments

2 participants


Mustache isn't in any way affiliated with HTML. So I create this feature request to make the use of "htmlentities" configurable by allowing to pass a custom function to either the constructor or the render function.

I'm using mustache in a non-HTML context, that's why I need a custom function to escape characters which are special in this context.

Quote from mustache(1): "Mustache is a logic-less templating system for HTML, config files, anything."


That's a good idea. Per the spec, mustache escapes as HTML, but there's no reason not to make that configurable.

@bobthecow bobthecow referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@bobthecow bobthecow referenced this issue from a commit
@bobthecow Add custom variable escapers.
cf. #86

 * Add `escape` Mustache constructor option. Expects something callable.
 * Update Compiler to either inline `htmlspecialchars` (old way) or a call to the custom escaper callback.
 * Update Compiler to statically compile charset.
 * Update template classname to account for charset and custom compilers.

This has been merged into both the dev and support/1.x branches. It will go into the next release of both.

@bobthecow bobthecow closed this

Nice, thank you.


No problem.

@groue groue referenced this issue in mustache/spec

Proposal: HTML vs. text templates #66

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.