Antaris / RazorEngine

Open source templating engine based on Microsoft's Razor parsing engine
http://antaris.github.io/RazorEngine
Other
2.14k stars 577 forks source link

Alternative to RazorEngine? #558

Open GFoley83 opened 5 years ago

GFoley83 commented 5 years ago

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?

marko444 commented 4 years ago

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

GMihalkow commented 4 years ago

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

kjmtks commented 4 years ago

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

matthewblott commented 4 years ago

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

This doesn't appear to be open source.

matthewblott commented 4 years ago

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

This will not work with .NET Core 3.0.

kjmtks commented 4 years ago

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

matthewblott commented 4 years ago

@GFoley83 that's the version I have been using

kjmtks commented 4 years ago

@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);
}
Wingjam commented 4 years ago

I also switched to RazorLight using .Net Core 3.0

jsgoupil commented 3 years ago

RazorLight does not support @helper. Just FYI.

jsgoupil commented 3 years ago

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.