adoconnection / RazorEngineCore

.NET6 Razor Template Engine
MIT License
576 stars 85 forks source link

Template Delegates are not supported #96

Closed SaphireLattice closed 2 weeks ago

SaphireLattice commented 2 years ago

It seems that they are added via the builder in RazorProjectEngine, with TemplateTargetExtension. But builder method is completely inaccessible and impossible to extend with current API? That's kinda surprising it is not accessible and not able to be extended...

adoconnection commented 2 years ago

we can fix that :)

SaphireLattice commented 2 years ago

I'm guessing passing it as part of the options would work?

Oh also, the builder allows setting the default base class from which the template inherits, meaning that there's no need to append "@inherits" for default stuff as a text to the template?

thomas-parrish commented 2 years ago

we can fix that :)

Are there still plans to implement this?

adoconnection commented 2 weeks ago

done in 2024.4.4 https://www.nuget.org/packages/RazorEngineCore/2024.4.1

IRazorEngineCompiledTemplate template1 = razorEngine.Compile("Hello <h1>@Model.Name</h1>", builder =>
{
    builder.Options.ProjectEngineBuilder = engineBuilder =>
    {
        engineBuilder.Features.Add(myCoolFeature);
    };
});