Alternative to RazorEngine?
Opened this issue · 11 comments
Looks like this project is dead and also has some issues working with Core and some Azure services (e.g. Azure Functions).
What are people using instead?
@GFoley83 if your goal is only to compile Razor view templates, you can use this solution https://dotnetstories.com/blog/Generate-a-HTML-string-from-cshtml-razor-view-using-ASPNET-Core-that-can-be-used-in-the-c-controlle-7173969632
Helped me a lot.
@GFoley83 I recommend RazorLight.
If you use it with .net core 3, please check it.
This doesn't appear to be open source.
@GFoley83 I recommend RazorLight.
If you use it with .net core 3, please check it.
This will not work with .NET Core 3.0.
@GFoley83 I recommend RazorLight.
If you use it with .net core 3, please check it.This will not work with .NET Core 3.0.
Try to use version 2.0.0-beta1.
@GFoley83 that's the version I have been using
@GFoley83 that's the version I have been using
It works in my project using .Net core 3.0 with following code:
async Task<string> Assemble(string viewString, YourModelType model)
{
var engine = new RazorLight.RazorLightEngineBuilder()
.UseMemoryCachingProvider().Build();
return engine.CompileRenderAsync("somekey", viewString, model);
}
I also switched to RazorLight using .Net Core 3.0
RazorLight does not support @helper
. Just FYI.
After a long research. @helper
is simply not available in .NET Core 3 but you can go around it.
But I found myself going with this:
https://github.com/EtiennePeeters/AzureFunctionsRazorEmailTemplateSample
I was able to run the out of the box Razor in an Azure Function.