Extensions for RazorEngineCore (ASP.NET Core 3.1.1 Razor Template Engine)
HTML (safe) encoded output by default using RazorEngineCorePageModel
or RazorEngineCorePageModel<T>
.
Template pre-compiler for RazorEngineCore.
Compile your RazorEngineCore Templates when building your solution/project, thus compiling them during runtime.
Precompiler
usage
// Setup the template for the precompiler [assembly: PrecompiledTemplate("sample", typeof(RazorEngineCorePageModel), "@Model.Name")] // Using the precompiled template var resourceTemplate = await PrecompiledTemplate.LoadAsync("sample"); await resourceTemplate.RunAsync(model: someModel);
PrecompiledTemplateAttribute
.RazorEngineCore.templates
.Support for (some) @Html
tags with custom RazorEngineCoreHtmlWriter
(to reduce external dependencies)
use: @("<div>string</div>")
out: <div>string</div>
use: @Html.Encode("<div>string</div>")
out: &lt;div&gt;string&lt;/div&gt;
use: @Html.AttributeEncode("<div>string</div>")
out: &lt;div>string&lt;/div>
use: @Html.Raw("<div>string</div>")
out: <div>string</div>
Using the default RazorEngineTemplateBase
with @Html
will result in an exception The name 'Html' does not exist in the current context
.
For RazorEngine
CompileFromFile(string fileName, ...) CompileFromFileAsync(string fileName, ...) CompileFromStream(StreamReader streamReader, ...) CompileFromStreamAsync(StreamReader streamReader, ...)
For RazorEngineCompiledTemplate<>
These enable direct Model usage w/o the need for the RazorEngineTemplateBase (PageModel) instance.
Run(object model = null) RunAsync(object model = null) Run<TModel>(TModel model = null) RunAsync<TModel>(TModel model = null)
@Html
tags.Razor image by Freepik
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4