Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed RazorTemplateEngine API #25215

Closed
NTaylorMullen opened this issue Aug 24, 2020 · 1 comment
Closed

Removed RazorTemplateEngine API #25215

NTaylorMullen opened this issue Aug 24, 2020 · 1 comment
Milestone

Comments

@NTaylorMullen
Copy link
Contributor

This is the discussion issue for aspnet/Announcements#433

Removed RazorTemplateEngine API

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

var projectEngine = 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

var item = projectEngine.FileSystem.GetItem(@"C:\Users\nimullen\source\repos\ConsoleApp4\ConsoleApp4\Example.cshtml", FileKinds.Legacy);
var output = projectEngine.Process(item);

// Things available
var syntaxTree = output.GetSyntaxTree();
var intermediateDocument = output.GetDocumentIntermediateNode();
var csharpDocument = output.GetCSharpDocument();

Category

ASP.NET

Affected APIs

  • RazorTemplateEngine
  • RazorTemplateEngineOptions

Issue metadata

  • Issue type: breaking-change
@ghost
Copy link

ghost commented Nov 12, 2020

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!

@ghost ghost closed this as completed Nov 12, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 12, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant