43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
// /**
|
|
// * File: TemplateDocument.cs
|
|
// * Author: haraldwolff
|
|
// *
|
|
// * This file and it's content is copyrighted by the Author and / or copyright holder.
|
|
// * Any use wihtout proper permission is illegal and may lead to legal actions.
|
|
// *
|
|
// *
|
|
// **/
|
|
using System;
|
|
using System.IO;
|
|
namespace ln.templates.html
|
|
{
|
|
public class TemplateDocument : DocumentElement
|
|
{
|
|
public long TemplateVersion { get; set; }
|
|
|
|
public TemplateDocument()
|
|
{
|
|
}
|
|
|
|
public void RenderTemplate(TextWriter contentWriter) => RenderTemplate(new RenderContext(contentWriter));
|
|
public void RenderTemplate(RenderContext renderContext,bool withoutDocType = false)
|
|
{
|
|
if (!withoutDocType)
|
|
renderContext.ContentWriter.Write("<!DOCTYPE html>");
|
|
|
|
foreach (Element element in Children)
|
|
{
|
|
if (element is TemplateElement templateElement)
|
|
{
|
|
templateElement.RenderTemplate(renderContext);
|
|
} else
|
|
{
|
|
renderContext.ContentWriter.Write(element.ToString());
|
|
}
|
|
}
|
|
|
|
renderContext.ContentWriter.Flush();
|
|
}
|
|
}
|
|
}
|