Upgrade to support v3 language (e.g. local functions)
The current RazorLight (excellent library, thank you!) supports the Razor 2.2 language syntax.
With ASP.NET Core 3.0 an updated language syntax and base library 3.0.0 and 3.1.0 have been introduced with Microsoft.AspNetCore.Razor.Language - is there any plan to upgrade RazorLight to support this?
Example of new language feature: local functions (a @Helper replacement)
<div>
@Hello()
</div>
@functions
{
void Hello()
{
<p>Hello world</p>
}
}
tl;dr: If you want to accept a PR, I'll review, but please include tests. Thank you.
Long answer:
The current RazorLight (excellent library, thank you!) supports the Razor 2.2 language syntax.
How did you determine it supports the Razor 2.2 language syntax?
It's called RazorLight for a reason: It's a sub-set of Razor. There are likely features missing, even from the Razor 2.2 language syntax.
is there any plan to upgrade RazorLight to support this?
It's an open source library and not a business - nothing is "planned". The original author, Ivan Balan, has been working on other projects while I help maintain the library. I'm happy to accept PRs, but I personally don't have any use for local functions in my projects, and never will, because they're not unit testable. I'd rather have static methods on a static class instead, because I can unit test those.
Thanks for the reply - yes I'll try to submit a PR for the upgrade.
I tried to create a Razor view with a @functions block and a method that contained HTML (like the old '@helper' syntax) and the template compilation step failed, so this is why I assumed it only supported 2.2 syntax. The 'helper' method was introduced in .NET Core 3.0
The way Razor works internally, and it's changed a bit from .net core version to version, is it's basically a set of plug-ins called directives (ugh - hate the angular-like vocabulary) and these directives help process "chunks" of text. Dave Glick, who maintains Wyam.io (a great static site generator), has written some blog posts about the internals: https://daveaglick.com/posts/the-bleeding-edge-of-razor
Have you had a chance to create a PR, @conficient? :)
Sorry work commitments since everyone came back has put it on the back burner. Feel free to close this issue if you wish.