question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Layout + html safe extension

See original GitHub issue

@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 https://github.com/adoconnection/RazorEngineCore/issues/65#issuecomment-954703223_

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
benmccallumcommented, Dec 2, 2021

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 🤦🏻‍♂️

0reactions
adoconnectioncommented, Dec 7, 2021

👌👌

Read more comments on GitHub >

github_iconTop Results From Across the Web

html.to.design
With html.to.design, convert any website into fully editable Figma designs. ... this Chrome extension is a companion to the html.to.design Figma plugin, ...
Read more >
HTML Layout Extensions
HTML Extensions To Improve Layout Control for Viewing and Printing Documents · Contents · Introduction · Column and Callout (region) Formatting.
Read more >
Safely insert external content into a page - Mozilla | MDN
When working with externally sourced content that you know is HTML, sanitizing the HTML is essential before it's added to a page. Best...
Read more >
HTML Programming with Visual Studio Code
HTML extensions ​​ Install an extension to add more functionality. Go to the Extensions view (Ctrl+Shift+X) and type 'html' to see a list...
Read more >
html.to.design | Figma Community
Figma Community plugin - Convert any website into fully editable Figma designs. Leverage an existing website and import its html to Figma to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found