DamianEdwards / RazorSlices

Lightweight Razor-based templates for ASP.NET Core without MVC, Razor Pages, or Blazor.
MIT License
297 stars 12 forks source link

Does this offer more flexibility than RCL? Do you plan to output Strings directly? #7

Closed zfcflower closed 1 year ago

zfcflower commented 1 year ago

Thank you very much for sharing, and I'm sure this library has its unique advantages, such as performance, zero allocation, and so on. But if you can answer my question, I'm sorry I don't know if this is the right question 😄

I used the RCL approach earlier, using the Razor template in miniApi to generate index pages and for the mail template. So here's the puzzle:

  1. Does this offer more flexibility than RCL?
  2. Do you plan to output html Strings directly?
DamianEdwards commented 1 year ago

This library is very much focused on being detached from MVC/Blazor but still attached to ASP.NET Core (for serving from Minimal APIs, etc.) and being "pay for play" with regards to features and performance, i.e. if you don't use a feature, you pay no performance penalty for it, while also attempting to get the simplest template to be as fast as possible. It's trying to do all of this while maintaining the Visual Studio editing experience for .cshtml files, (e.g. not using a custom Razor compiler host to add/remove features which then don't match what you see in the editor).

When you say "RCL" I assume you mean Razor Class Libraries? If so, how are you returning those from a minimal API? Templates in RCLs are still tied to MVC or Blazor (.cshtml vs. .razor) so can't be easily rendered from Minimal APIs without manually adding a bunch of infrastructure (e.g. like this).

zfcflower commented 1 year ago

Thank you very much for your reply! Because there is no better solution, so use Razor.Templating.Core, It is the use of Razor SDK for precompiling the views,Combined with Razor Class Libraries, Razor is deployed as a separate class library and supports .cshtml files experience in Visual Studio.

Thanks so much, can't wait to try RazorSlices!!