You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The RazorTemplateEngine API was removed in favor of RazorProjectEngine.
Version introduced
3.0
Old behavior
A template engine could be created and used to parse and generate code for Razor files
New behavior
A RazorProjectEngine can be created and fed the same type of information as a RazorTemplateEngine to parse and generate code for Razor files. It also provides extra levels of configurability.
Reason for change
RazorTemplateEngine was too coupled to our existing implementations and ultimately led to more questions when trying to properly configure a Razor parsing/generation pipeline.
Recommended action
Use RazorProjectEngine instead of RazorTemplateEngine.
Creating & configuring the RazorProjectEngine
varprojectEngine= RazorProjectEngine.Create(
RazorConfiguration.Default,
RazorProjectFileSystem.Create(@"C:/Users/nimullen/source/repos/ConsoleApp4/ConsoleApp4"),builder =>{ builder.ConfigureClass((document,classNode)=>{ classNode.ClassName ="MyClassName";// Can also configure other aspects of the class here.});// More configuration can go here});
Generating code for a Razor file
varitem= projectEngine.FileSystem.GetItem(@"C:\Users\nimullen\source\repos\ConsoleApp4\ConsoleApp4\Example.cshtml", FileKinds.Legacy);varoutput= projectEngine.Process(item);// Things availablevarsyntaxTree= output.GetSyntaxTree();varintermediateDocument= output.GetDocumentIntermediateNode();varcsharpDocument= output.GetCSharpDocument();
Category
ASP.NET
Affected APIs
RazorTemplateEngine
RazorTemplateEngineOptions
Issue metadata
Issue type: breaking-change
The text was updated successfully, but these errors were encountered:
Thank you for contacting us. Due to a lack of activity on this discussion issue we're closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn't been addressed yet, please file a new issue.
This issue will be locked after 30 more days of inactivity. If you still wish to discuss this subject after then, please create a new issue!
This is the discussion issue for aspnet/Announcements#433
Removed RazorTemplateEngine API
The
RazorTemplateEngine
API was removed in favor ofRazorProjectEngine
.Version introduced
3.0
Old behavior
A template engine could be created and used to parse and generate code for Razor files
New behavior
A
RazorProjectEngine
can be created and fed the same type of information as aRazorTemplateEngine
to parse and generate code for Razor files. It also provides extra levels of configurability.Reason for change
RazorTemplateEngine
was too coupled to our existing implementations and ultimately led to more questions when trying to properly configure a Razor parsing/generation pipeline.Recommended action
Use
RazorProjectEngine
instead ofRazorTemplateEngine
.Creating & configuring the RazorProjectEngine
Generating code for a Razor file
Category
ASP.NET
Affected APIs
Issue metadata
The text was updated successfully, but these errors were encountered: