toddams / RazorLight

Template engine based on Microsoft's Razor parsing engine for .NET Core
Apache License 2.0
1.51k stars 261 forks source link

Add Razor Class Library sample #396

Open knuxbbs opened 3 years ago

knuxbbs commented 3 years ago

Is your feature request related to a problem? Please describe. There isn't any sample using cshtml files, only strings. I think that the majority of users come to this repo to found a solution that uses the capabilities of Razor views and pages.

Describe the solution you'd like Create a project which uses a Razor Class Library to share templates with another project.

knuxbbs commented 3 years ago

I've tried to create a sample here, but without success: https://github.com/knuxbbs/RazorLightSample

jzabroski commented 3 years ago

@knuxbbs Can you elaborate on what you mean "without success"? Then I will start poking around. Thanks.

knuxbbs commented 3 years ago

Well, I got it with the help of @maxbanas in https://github.com/toddams/RazorLight/issues/378#issuecomment-732994641.

But do you think there should an example with cshtml files in the samples folder? If not, you can close this issue.

jzabroski commented 3 years ago

@knuxbbs I definitely want to add samples for various scenarios, like hosting a net48 WPF app. That would cover some scenarios.

The reason I want to add samples is a lot of people find out about RazorLight from blog posts that may or may not have the best practices. Unfortunately, GitHub doesn't give me Google Analytics type insights to see what's driver traffic, and neither does Nuget. If it did, I could probably contact blog authors and ask them to amend blog posts with some incorrect practices.

Vincentvwal commented 3 years ago

A while back i write the following, which is something we are using within our company. Note that this however still uses an old release, however it should work on the new ones as well. https://github.com/Vincentvwal/RazorLightExample

This also comes with the following guide (also, not updated for now) https://vincentvwal.github.io/razorlight/templates/razor/email/2020/11/18/Adding-an-email-library-in-.Net-Standard-2.1-with-Razor-templates.html

This isn't really using RCL, but the main reason behind that is that when i included razorLight within RCL, my visual studio stopped working.