I am trying to use a customized base class for the templates, but it results in an error when rendering the template as the base class in the generated code is still the default TemplateBase:
public abstract class MyTemplateBase : RazorTemplates.Core.TemplateBase
{
}
RazorTemplates.Core.Template
.WithBaseType<MyTemplateBase>(t => t.Model = model)
.Compile("test").
.Render(model);
The generated code is:
namespace RazorTemplates {
using System;
using System.Collections.Generic;
using System.Linq;
public class Template_1 : RazorTemplates.Core.TemplateBase {
public Template_1() {
}
public override void Execute() {
WriteLiteral("test");
}
}
}
As you can see the TemplateBase is still being used and that causes the following class cast exception during the rendering: Unable to case object of type 'RazorTemplates.Template_1' to type 'MyTemplateBase'
I am trying to use a customized base class for the templates, but it results in an error when rendering the template as the base class in the generated code is still the default TemplateBase:
The generated code is:
As you can see the TemplateBase is still being used and that causes the following class cast exception during the rendering: Unable to case object of type 'RazorTemplates.Template_1' to type 'MyTemplateBase'