Make escape function configurable #86

Closed
Prinzhorn opened this Issue Mar 10, 2012 · 4 comments

Projects

None yet

2 participants

@Prinzhorn

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

@bobthecow
Owner

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

@bobthecow bobthecow added a commit that referenced this issue Mar 15, 2012
@bobthecow Allow custom `escape` callbacks.
cf. #86
f6f9d3f
@bobthecow bobthecow added a commit that referenced this issue Mar 15, 2012
@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.
23a4bb0
@bobthecow
Owner

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 Mar 15, 2012
@Prinzhorn

Nice, thank you.

@bobthecow
Owner

No problem.

@groue groue referenced this issue in mustache/spec Jan 27, 2013
Open

Proposal: HTML vs. text templates #66

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment