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

Layout + html safe extension #87

Closed
adoconnection opened this issue Nov 30, 2021 · 6 comments
Closed

Layout + html safe extension #87

adoconnection opened this issue Nov 30, 2021 · 6 comments

Comments

@adoconnection
Copy link
Owner

@adoconnection , I seem to have a problem after following the layout + html safe templating docs whereby the @RenderBody() portion is html encoded... any suggestions?

It's like it's encoding the @RenderBody() part when it's already safe/encoded.

Edit:
I think I have a solution, shout out if I'm missing any issues though.

  1. Modify MyTemplateBase<T> Include and RenderBody methods to return object and be virtual.
  2. Modify MyHtmlTemplateBase<T> (which inherits MyTemplateBase<T>) by overriding those two methods and have them return Raw(base.Include/RenderBody);.
  3. Need to move RawContent into its own internal class as it was previously private inside MyTemplateBase.

Like this, when WriteAsync is called with the RenderBody() or Include() result, it's already a RawContent and the avoidance of html encoding happens.

Hope that helps someone else. Almost wonder if it's worth adding this into the docs.

Originally posted by @benmccallum in #65 (comment)

@adoconnection
Copy link
Owner Author

@benmccallum I moved your last comment to a new issue. Please drop a line if the problem is solved or not.

@benmccallum
Copy link

Thanks @adoconnection , sorry for piling on another issue :P

I've resolved my issue, but should we get my gist into a sample app or documentation so this combo is clear to setup for folks?

@benmccallum
Copy link

Gosh, sorry I'm not sure how I missed the extensions part of the readme which points to: https://github.com/wdcossey/RazorEngineCore.Extensions

Perhaps I should've just used that all along 🤦🏻‍♂️

@adoconnection
Copy link
Owner Author

No worries

@benmccallum
Copy link

Feel free to close this if you'd prefer to point to the other package. Here's my gist again for anyone it helps.

@adoconnection
Copy link
Owner Author

👌👌

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