SharpRazor is a lightweight templating system based on the powerful Razor templating stack.
var razorizer = new Razorizer();
var result = razorizer.Parse("<p>Hello @Model.Name!</p>", new { Name = "Razor" });Output:
<p>Hello Razor!</p>SharpRazor provides the following features:
- Simple and easy interface, with a single entry point
Razorizerclass and mainly two methods: Razorizer.Parseto directly parse a templateRazorizer.Compileto precompile template page- C# Code Language and HTML Markup Language (aka
cshtmlfiles) - MVC3 Model aka
@modeldirective - MVC3 Layout and Sections
- Caching of generated page template types
- Custom page template class inheriting from
SharpRazor.PageTemplate<TModel> - Allow debugging of template code (breakpoints, step-in...etc. from VS debugger) when loading template from a location on the disk (By specifying a
templateFilePath). - Very lightweight, packed into an assembly weighting less than 40Kb (without counting
System.Web.Razordependency) - Compatible with
.NET 4.5+andSystem.Web.Razor 3.0
You can download SharpRazor binaries directly from nuget.
MIT