Today I found myself playing around with razorlight:
Use Razor to build templates from Files / EmbeddedResources / Strings / Database or your custom source outside of ASP.NET MVC. No redundant dependencies and workarounds in pair with excellent performance and .NET Standard 2.0 and .NET Core 3.0 support.
Quick example on the setup:
var engine = new RazorLightEngineBuilder()
// required to have a default RazorLightProject type, but not required to create a template from string.
.UseEmbeddedResourcesProject(typeof(Program))
.UseMemoryCachingProvider()
.Build();
string template = "Hello, @Model.Name. Welcome to RazorLight repository";
ViewModel model = new ViewModel() { Name = "John Doe" };
string result = await engine.CompileRenderStringAsync("templateKey", template, model);
This can be utilized to read .cshtml files and send them in an email as HTML. Utilize this with Puppeteer to turn your HTML into a PDF document!
Use your creativity to make the most out of this handy library!
Enjoy!