I have a Model with property Content which contains HTML string.
var model = new { Content = ... }
Razor.Parse(templateBody, model)
How can I render this string using standalone Razor.
I tried:
@(new HtmlString(Model.Content))
and also
@(HttpUtility.HtmlDecode(Model.Content))
Model.Content renders always HTML-escaped.
In RazorEngine library special "do-not-escape-me" type is
RazorEngine.Text.IEncodedString
. Use simple helper method on template base class:To convince VS and Resharper to give you IntelliSense add following line at the top of template:
this should work
Html.Raw(Model.Content)