RazorLight

Template engine based on Microsoft's Razor parsing engine for .NET Core

APACHE-2.0 License

Stars
1.5K

Bot releases are visible (Hide)

RazorLight - Version 2.3.1 Latest Release

Published by jzabroski almost 2 years ago

Improvements

  1. Add RepositoryUrl #512
  2. Missing space in exception message #498

Milestone Notes

Associated milestone tracker for v2.3.1:
https://github.com/toddams/RazorLight/milestone/19

RazorLight - Version 2.3.0

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.

RazorLight - Version 2.2.0

Published by jzabroski about 2 years ago

Issues By Milestone

#491 Feature Request: Generate an assembly and persist it to disk (Precompile views)

PRs By Milestone

#492 Implement the RazorLight.Precompile tool
#500 Fix broken tests on Unix (related to RazorLight.Precompile)

RazorLight - Version 2.1.0

Published by jzabroski over 2 years ago

Issues By Milestone

#481 System.UriFormatException: Invalid URI: The hostname could not be parsed (Fixed by @Xtansia #489 )

PRs By Milestone

  • Docs updated by @mwasson74 , @vdurante
  • Verify dependency updated by @SimonCropp
  • Tests added by @jzabroski
RazorLight - Version 2.0.0

Published by jzabroski over 2 years ago

RTM.

RazorLight - Version 2.0.0-rc.6

Published by jzabroski over 2 years ago

💖 Improvements

#467 : Support for .NET 6.0 (Fixes #460)

RazorLight - Version 2.0.0-rc.4

Published by jzabroski almost 3 years ago

RazorLight - Version 2.0.0-rc.3

Published by jzabroski over 3 years ago

RazorLight - Version 2.0.0-rc.2

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

RazorLight - Version 2.0.0-rc.1

Published by jzabroski almost 4 years ago

  • Removed Obsolete InplaceStringBuilder and replaced with stringbuilder. #380 (@ADNewsom09)
    • required for .NET 5.0 support to work
  • .NET 5.0 support #389 (@nm-a)
RazorLight - v2.0.0-beta9

Published by jzabroski over 4 years ago

#349 - Fixes #349 dotnet pack bug causes .netcoreapp3.1 TFM projects issues @(@jzabroski)

RazorLight - v2.0.0-beta8

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)

RazorLight - v2.0.0-beta7

Published by jzabroski over 4 years ago

  • Fixes #322 via commit 2d9c031 (@jzabroski )
RazorLight - v2.0.0-beta6

Published by jzabroski over 4 years ago

  • Fixes #311 (via @HakanL PR #312): Incorrect template key when using constructor that takes assembly.
  • Release Management improvement: Cleaned up Sandbox, Sample and RazorLight.Precompile projects to have IsPackable=False
RazorLight - v2.0.0-beta5

Published by jzabroski over 4 years ago

  • Fixes #287 via #310 (@matthewwren viz a viz @chancie86 )
RazorLight - 2.0.0-beta2

Published by toddams almost 5 years ago

What's new

  • #123 Template now shares model with layout.
  • #107 Embedded project can now accept Assembly + root namespace as a string, instead of Type of root object
  • #152 Allow FileSystemProject to set Extension ( @KorsG )
  • #180 Add ability to exclude assemblies from metadata references ( @mscrivo )
  • #278 Add netcore 3.0 support ( @gjunge )

Bug fixes:

  • #103 - Fixed race condition compilation bug
  • #134 - Fixed rendering issues with included templates
  • #135 - Fixed ViewBag doesn't work in nested templates (@deckertron9000)
  • #141, #147, #133 - Resolve MetadataReferences without using DependencyContext on Full .NET Framework (@colinbull )
  • #153 - Fixed MemoryCachingProvider file naming (@KorsG )
  • @Raw() will not throw NullReferenceException on null or empty value (@ReinisV1 )

Breaking changes

  • EngineFactory will trigger build error. Marked completely Obsolette. Use RazorLightEngineBuilder instead
  • When template you want to render does not exist, TemplateNotFoundException will be throws instead of InvalidOperationException
RazorLight - 2.0.0-beta1

Published by toddams almost 7 years ago

What's new?

Breaking changes

  • Added new type: RazorLightEngineBuilder that comes to replace EngineFactory, as too many overloads are annoying
  • EngineFactory masked as Obsolete.
  • EngineFactory.RazorEngine is moved to DefaultRazorEngine.Instance
  • ICompilationService.CompileAndEmit renamed to CompileAsync and returns Task
  • DefaultCachingProvider renamed to MemoryCachingProvider

Note: there was a major refactoring, you may find some classes are moved to another namespaces

New features

  • 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

Bug fixes

  • Fix ViewBag not passed to the engine #97
  • Close stream after read - #120
  • Fix concurrent template build fails - #103
RazorLight - 2.0-alpha3

Published by toddams about 7 years ago

What is new?

String rendering is back!

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); 

Additional metadata references

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);
RazorLight - 2.0-alpha2

Published by toddams about 7 years ago

What is new?

  • Added support for includes via @{ await IncludeAsync("key", model); }
  • Disable encoding

As always, you can avoid encoding using @Raw() function

@Raw(Model.Data)

Or disable encoding for entire document

@{
    DisableEncoding = true;
}

Breaking change

  • GetTemplateAsync is now called CompileTemplateAsync
RazorLight - 2.0-alpha1

Published by toddams about 7 years ago

2.0 alpha version is out

This is not a full list of changes, only key notes about the changes and important info

  • There are a lot of breaking changes. Project literally has been made from scratch
  • IRazorLight interface is still there. There is no "Parse" method. Use "CompileRenderAsync" instead (method names might change in future releases)
  • EngineFactory no longer static
  • No IEngineConfiguration yet.
  • No MVC version with @Inject yet.
  • No ViewStarts yet
  • FileSystem templates are not tracked and therefore are not invalidated from cache yet when you change them
  • No string caching (Most people used it to for templates that are taken from database. Recommended approach is to create custom RazorLightProject class that will load your templates from database. That's all you need and this way, your templates will be cached). I will create a sample tomorrow with EntityFramework and NpgSql

So what is implemented?

  • Basic Razor support
  • Model
  • Layout,
  • Sections
  • Caching
Package Rankings
Top 9.59% on Proxy.golang.org
Badges
Extracted from project README
NuGet Pre Release NuGet downloads Join the chat at https://gitter.im/gitterHQ/gitter
Related Projects