Releases: toddams/RazorLight
Releases · toddams/RazorLight
1.1.0
1.0.1
What's new
- #49 TemplateCompilationException now includes line and column number where an error occured
- #46 Added new overload for Parse() method. Now you can set a PreCenderCallback for each page individually. (Before you could only add callbacks to IEngineConfiguration that are applied for each page)
Bug fixes
- Fix #47 (ExpandoObject as model type throws RuntimeBinderException)
1.0.0
1.0.0-rc2
What's new:
- Project migrated to MSBuild / *.csproj
- For the convenience, compilation errors are now shown in Exception Message. No need to inspect CompilationErrors.
- EngineFactory now returns IRazorLightEngine (was RazorLightEngine)
- Minor bug fixes
1.0.0-rc1
Out first Release Candidate!
This release comes out with some improvements and refactorings. We are planning to roll up a stable version soon
ParseString()
is extracted to an extension method (under RazorLight.Extensions namespace)- PreRenderCallbacks moved to
IEngineConfiguration
- While searching for Layout file - instead of
InvalidOperationException
-RazorLightException
is thrown - No more
AggregateExceptions
. I'm erasing annoying AggregateExceptions from code. Please, open an issue If you see it again somewhere
1.0.0-beta6
1.0.0-beta5
Full .NET Support arrived!
- Now you can use RazorLight with a Full .NET Framework v4.5.1 and higher
ASP.NET MVC Core integration
New package brings ASP.NET MVC Core integration which allows you to inject services into your templates via built in Dependency Injection container
-
Add package
Install-Package RazorLight.MVC
-
Add RazorLight services in Startup.cs
public void ConfigureServices(IServiceCollection services)
{
....
services.AddRazorLight("/Views"); // <- This one
....
}
- Retreive IRazorLightEngine instance from controller constructor
private readonly IRazorLightEngine engine;
public HomeController(IRazorLightEngine engine)
{
this.engine = engine;
}
- Inject services to your templates
@inject MyProject.TestViewModel myModel
Small fixes
@include now works in Layout and ViewStart pages as well (#12)
1.0.0-beta4
This release brings you Include feature
Example
@model MyProject.TestViewModel
<div>
Hello @Model.Title
</div>
@{ await IncludeAsync("SomeView.cshtml", Model); }
First argument takes a key of the template to resolve, second argument is a model of the view (can be null)
1.0.0-beta3
New features
- Use
Raw()
method to output model value without encoding ( #7 )
Changes
- Fix #5
- Rename PageCacheItem and PageCacheResult to PageLookupItem and PageLookupResult
- Removed
IMemoryCache
fromDefaultPageLookup
- Added new IPageFactory with caching -
CachingPageFactory
- PageLookupResult default constructor removed. Use PageLookupResult.Failed instead
1.0.0-beta2
Changes
- Pass ITemplateConfiguration to EngineFactory #3
IEngineConfiguration config = EngineConfiguration.Default;
config.Namespaces.Add("My.Custom.Namespace");
var engine = EngineFactory.CreatePhysical("root/folder", config);
- Pass a ViewBag to Parse method. #4
Note: Viewbag is accessible both from the template page and it's layout.
Code
var model = new MyModel()
{
Title = "Test"
};
//create a dynamic viewbag
dynamic viewBag = new ExpandoObject();
viewBag.DataForLayoutPage = "Hello world";
string result = engine.Parse("key", model, viewBag);
Template
@model MyViewModel
@{
Layout = "layout_key";
}
<div>Hello @ViewBag.Title</div>