Template engine based on Microsoft's Razor parsing engine for .NET Core
APACHE-2.0 License
Bot releases are hidden (Show)
Associated milestone tracker for v2.3.1:
https://github.com/toddams/RazorLight/milestone/19
Published by jzabroski about 2 years ago
This release publishes to nuget.org @MarkKharitonov 's Razorlight.Precompile package.
See previous version 2.2.0 release notes for details.
Published by jzabroski about 2 years ago
#491 Feature Request: Generate an assembly and persist it to disk (Precompile views)
#492 Implement the RazorLight.Precompile tool
#500 Fix broken tests on Unix (related to RazorLight.Precompile)
Published by jzabroski over 2 years ago
#481 System.UriFormatException: Invalid URI: The hostname could not be parsed (Fixed by @Xtansia #489 )
Published by jzabroski over 2 years ago
RTM.
Published by jzabroski over 2 years ago
#467 : Support for .NET 6.0 (Fixes #460)
Published by jzabroski almost 3 years ago
Published by jzabroski over 3 years ago
Published by jzabroski almost 4 years ago
#391 - Change exception type/message when project item does not exist (@maxbanas) - to help people troubleshoot issues like #378
#392 - Change targeting for .Net standard 2.0 (@Vincentvwal) - Fixes #390
Generated from: https://github.com/toddams/RazorLight/milestone/11?closed=1
Published by jzabroski almost 4 years ago
Published by jzabroski over 4 years ago
#349 - Fixes #349 dotnet pack
bug causes .netcoreapp3.1 TFM projects issues @(@jzabroski)
Published by jzabroski over 4 years ago
#335 - Fixed spelling errors in the code (@SimonCropp)
#309 - Added regression tests for common Razorlight renderer cases (@weyert)
#346 - Introduce Verify for section
approval tests (@SimonCropp)
#308 - Fixed "The name 'section' does not exist in the current context in .net core 3" (@jzabroski)
Published by jzabroski over 4 years ago
Published by jzabroski over 4 years ago
Published by jzabroski over 4 years ago
Published by toddams almost 5 years ago
Published by toddams almost 7 years ago
Note: there was a major refactoring, you may find some classes are moved to another namespaces
Templates that are resolved from FileSystem are now invalidated from MemoryCache when you change it.
You can now create an engine without a project, if you want to only create templates from strings - #110
It is possible now to create engine without caching provider
Add ability to set operating assembly (uses EntryAssembly if not specified)
Disable encoding for the entire document with template property "DisableEncoding" - #106
Published by toddams about 7 years ago
We added rendering of the strings back! And now they are cached, so you will not be affected by bad performance.
Note: if you store your templates in database - it is recommended approach to define custom RazorLightProject that fetches templates from database and create RazorLightEngine passing your implementation to it. This way, engine will your RazorLightProject to resolve layouts. String rendering is just another option for some exclusive use cases when you have microservice structure and pass templates between nodes, so you might not need it at all.
Here is an example of RazorLightProject that uses EntityFramework to get templates from database- https://github.com/toddams/RazorLight/blob/dev-2.0/samples/RazorLight.Samples/Program.cs
string templateKey = "key";
string result = await engine.CompileRenderAsync(templateKey , "Hello @Model.Name", new { Name = "Johny" });
//Returns true, so next time you render template with this key - it will not be compiled, but taken from cache
engine.TemplateCache.Contains(templateKey);
When RazorLight compiles your template - it loads all the assemblies from your entry assembly and creates MetadataReference from it. This is a default strategy and it works in 99% of the time. But sometimes compilation crashes with an exception message like "Can not find assembly My.Super.Assembly2000". In order to solve this problem you can pass additional metadata references to RazorLight.
var options = new RazorLightOptions();
var metadataReference = MetadataReference.CreateFromFile("path-to-your-assembly")
options.AdditionalMetadataReferences.Add(metadataReference );
var project = new FileSystemRazorProject("path-to-your-views");
var engine = new EngineFactory().Create(project, options);
Published by toddams about 7 years ago
As always, you can avoid encoding using @Raw() function
@Raw(Model.Data)
Or disable encoding for entire document
@{
DisableEncoding = true;
}
GetTemplateAsync
is now called CompileTemplateAsync
Published by toddams about 7 years ago
This is not a full list of changes, only key notes about the changes and important info
So what is implemented?