toddams/RazorLight

Add Razor Class Library sample

Opened this issue · 5 comments

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.

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

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

Well, I got it with the help of @maxbanas in #378 (comment).

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

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

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.