/// <inheritdoc />
public virtual void Render(TextWriter writer, TemplateContext context)
{
if (templateResult == null)
{
if (this.Context.Mode == EngineMode.Interpreted)
{
templateResult = context.InterpretTemplate(this.TemplateKey, this.reader);
}
else
{
templateResult = context.CompileTemplate(this.TemplateKey, this.reader);
}
if (templateResult == null)
{
throw new TemplateException($"template error.");
}
}
try
{
templateResult.Render(writer, context);
}
catch (System.Exception e)
{
context.AddError(e);
}
}