Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent escaping html entities #24

Closed
matyus opened this issue Oct 17, 2014 · 3 comments
Closed

prevent escaping html entities #24

matyus opened this issue Oct 17, 2014 · 3 comments

Comments

@matyus
Copy link

matyus commented Oct 17, 2014

I have file paths in the data that I'm injecting into my templates, but the rendering engine converts slashes to html entities: / becomes / when rendered.

Is there an existing option that gives me control over this?

@corpulentcoffee
Copy link
Contributor

The easiest way to do this today is to use triple braces, e.g. {{{field}}}, to disable the escaping.

(There is an outstanding pull request for this at #14 to add a target-wide flag to disable the escaping but it wasn't merged at the time. It would just need to be rebased, cleaned up, and have some unit tests added. Since folks often use mustache for output other than HTML, it would be helpful to have.)

@matyus
Copy link
Author

matyus commented Nov 7, 2014

Thanks @corpulentcoffee, the triple brace trick is the simple solution for sure! I completely forgot that mustache is capable of that.

With regards to pull-request #25, what does it actually offer that the triple braces don't already do? I would probably vote against the pull-request if it doesn't do anything more than what the triple brace escaping already offers...

@corpulentcoffee
Copy link
Contributor

@matyus, having options.escape = true in #25 doesn't offer any significant benefit above and beyond triple braces (other than a minor convenience).

The options.escape = function (text) { return ... } variation, though, would allow a user to specify a custom escape format for non-HTML formats (e.g. making sure commas and quotes are handled properly in CSV output). If someone were using a file- or URL-based input source for their data to generate their output, being able to specify a custom escape function might be the sanest way to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants