RickStrahl / Westwind.RazorHosting

Hosting the Razor Runtime outside of ASP.NET/MVC for use in non-Web .NET applications.
144 stars 32 forks source link

Razor engine crashes if @helper{ } is used in the template #4

Closed archnae closed 7 years ago

archnae commented 10 years ago

... because in RazorEngine.CreateHost the Razor creates default System.Web.Razor.Generator.GeneratedClassContext instance iwith only 3 arguments out of 6. adding lines var nonDefault = new System.Web.Razor.Generator.GeneratedClassContext("Execute", "Write", "WriteLiteral", "WriteTo", "WriteLiteralTo", "NestedHelper"); host.GeneratedClassContext = nonDefault;

to Core\RazorEngine.cs at line 532 allows to create custom templates that support helpers.

RickStrahl commented 7 years ago

Looks like this works now in 3.x and newer.