{"repo":"ltrzesniewski/RazorBlade","free":true,"listed":false,"github":"https://github.com/ltrzesniewski/RazorBlade","clone":"git clone https://github.com/ltrzesniewski/RazorBlade.git","description":"Compile Razor templates at build-time without a dependency on ASP.NET.","language":"C#","stars":176,"topics":["razor","template"],"license":"MIT","category":"saas-starters-boilerplates","readme_excerpt":"RazorBlade Compile Razor templates at build-time without a dependency on ASP.NET. RazorBlade is meant to be lightweight and self-contained : cshtml files are compiled into C# classes at build-time with a Roslyn source generator. No reference to ASP.NET is required. A simple base class library is provided by default, but it can also be embedded into the target project, or even replaced by your own implementation. Usage This package will generate a template class for every .cshtml file in your project. The generated classes will inherit from RazorBlade.HtmlTemplate by default, though it is advised to specify the base class explicitly to get the best IDE experience: snippet source anchor A version with a model is also available for convenience. The following will add a Model property and a constructor with a ModelType parameter: snippet source anchor Please note that this will cause a constructor with a ModelType parameter to be added to the generated class, which may cause false errors to be shown in some IDEs. Further documentation is provided below. Example The following template, in the ExampleTemplate.cshtml file: snippet source anchor Will generate the following class in your project: That you can use like the following: snippet source anchor With a model A similar template with a model would be: snippet source anchor Instantiating the generated class requires a model argument: snippet source anchor Since this generates a constructor with a GreetingModel parameter in the T","default_branch":null,"files":null,"tree":[],"storefront":"/r/ltrzesniewski","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/ltrzesniewski/RazorBlade/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}