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

Option to disable HTML encoding of values #119

Closed
imsedim opened this issue May 19, 2016 · 6 comments
Closed

Option to disable HTML encoding of values #119

imsedim opened this issue May 19, 2016 · 6 comments

Comments

@imsedim
Copy link
Contributor

imsedim commented May 19, 2016

Even though Handlebars is mainly used for producing HTML templates, it's a great tool that could be used for generating any other types of content.

With Handlebars.Net there is a caveat though - HTML escape is always used (unless explicitly turned off in the template or helper), meaning that any non-HTML template would have a lot of unnecessary noise ({{{...}}} or custom helpers) to alleviate this (one of the reasons why it matters is that EncodedTextWriteris a bit too strict and encodes everything above char 159, compared to Handlebars.js that only encodes symbols &<>"'`=)

The handlebars.js has an option noEscape which is helpful in exactly this situation.

So this issue is basically a feature request to include this noEscape capability in the Handlebars.Net either in the form of configuration option or as an extension point for custom-written TextWriter

@imsedim
Copy link
Contributor Author

imsedim commented May 19, 2016

The customizable TextWriter seems to be relatively straight forward fix, so if there are no objections on your side, I can make a PR

@Breate
Copy link

Breate commented May 19, 2016

Can you provide a solution to fix encoding cause i have a same issue.

@rexm
Copy link
Member

rexm commented May 19, 2016

Sure, there is a configuration object hook we've discussed turning into an options hash that works like the one in the JS library. And passing a standard text writer through the chain shouldn't be too hard. Look forward to the PR

@imsedim
Copy link
Contributor Author

imsedim commented May 20, 2016

Posted the PR

@rexm
Copy link
Member

rexm commented May 20, 2016

Fixed in #120, released in nuget package version 1.7.0

@rexm rexm closed this as completed May 20, 2016
@imsedim
Copy link
Contributor Author

imsedim commented May 21, 2016

Example of how to turn off the encoding:

var configuration = new HandlebarsConfiguration { TextEncoder = null };

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

3 participants