RazorEngine icon indicating copy to clipboard operation
RazorEngine copied to clipboard

Alternative to RazorEngine?

Open GFoley83 opened this issue 6 years ago • 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 avatar Sep 05 '19 11:09 GFoley83

https://sharpscript.net/usecases/email-templates

marko444 avatar Oct 09 '19 11:10 marko444

@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.

GMihalkow avatar Oct 15 '19 09:10 GMihalkow

@GFoley83 I recommend RazorLight. If you use it with .net core 3, please check it.

kjmtks avatar Oct 17 '19 09:10 kjmtks

https://sharpscript.net/usecases/email-templates

This doesn't appear to be open source.

matthewblott avatar Oct 21 '19 12:10 matthewblott

@GFoley83 I recommend RazorLight. If you use it with .net core 3, please check it.

This will not work with .NET Core 3.0.

matthewblott avatar Oct 21 '19 12:10 matthewblott

@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.

kjmtks avatar Oct 23 '19 05:10 kjmtks

@GFoley83 that's the version I have been using

matthewblott avatar Oct 23 '19 08:10 matthewblott

@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);
}

kjmtks avatar Oct 25 '19 06:10 kjmtks

I also switched to RazorLight using .Net Core 3.0

Wingjam avatar Dec 16 '19 19:12 Wingjam

RazorLight does not support @helper. Just FYI.

jsgoupil avatar Oct 15 '20 00:10 jsgoupil

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.

jsgoupil avatar Oct 16 '20 14:10 jsgoupil