Skip to content

Releases: toddams/RazorLight

1.0.0-beta1

07 Aug 17:55
Compare
Choose a tag to compare
1.0.0-beta1 Pre-release
Pre-release

This release brings Layout, _Viewstart pages support, sections and custom template namespaces. API is completely reworked.

New features

  • Use ITemplateManager(string key) to resolve a templates. For files, Key - is a relative path to the view. For embeded resources - it's a name of the resourse.
  • Layout pages
@model MyModel
@{
    Layout = "_Layout.cshtml"; // <- This is a key of the layout page
}
  • Sections

Layout.cshtml:

@RenderSection("section-name", required : false)

View.cshtml:

@section section-name
{
    <div>It is a content inside a section</div>
}
  • ViewStart pages. (Same as with ASP.NET MVC.)
  • Custom namespaces. To add custom namespaces to your templates, use ITemplateConfiguration.Namespaces (ISet<string)

Breaking changes:

  • ConfigurationOptions removed. Use ITemplateConfiguration instead.
  • AdditionalMetadataReferences and LoadDependenciesFromEntryAssembly are removed. Use IMetadataResolver to provide an additional metadata references to RazorLight compilation service
  • Parameterless constructor of RazorLightEngine was removed. Use static EngineFactory class instead.

Before:

var config = new ConfigurationOptions() { ViewsFolder = "C:/path/to/folder" }
var engine = new RazorLightEngine(config);
string result = engine.ParseFile("Test.cshtml", model);

After:

var engine = EngineFactory.CreatePhysical("C:/path/to/folder");
string result = engine.Parse("Test.cshtml", model);
  • ParseFile method is removed. Use Parse method instead with a FileSystemTemplateManager to resolve a template (ParseString method is still there)

Notes

  • To comply with Nuget versioning guidlines, version was changes from 0.0.1 to 1.0.0-beta1
  • Package is under active development and there might be breaking changes in a new releases. I expect to ship 3-4 betas and then go to stable, sorry for inconvenience, to create something good you must create at least something and then find the room for improvements

v0.0.1

24 Jul 13:08
Compare
Choose a tag to compare

First release with initial features:

  • Parse string
  • Parse files
  • Caching
  • Recompile cached view on file content change
  • Anonymous types models
  • Strongly typed views
  • Loading models from extenral assemblies