MustacheSharp/mustache-sharp/StaticGenerator.cs

55 lines
1.2 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.IO;
namespace mustache
{
/// <summary>
/// Generates a static block of text.
/// </summary>
internal sealed class StaticGenerator : IGenerator
{
/// <summary>
/// Initializes a new instance of a StaticGenerator.
/// </summary>
public StaticGenerator()
{
}
/// <summary>
/// Gets or sets the linked list node containing the current generator.
/// </summary>
public LinkedListNode<IGenerator> Node
{
get;
set;
}
/// <summary>
/// Gets or sets the static text.
/// </summary>
public string Value
{
get;
set;
}
/// <summary>
/// Removes the static text from the final output.
/// </summary>
public void Prune()
{
if (Node != null)
{
Node.List.Remove(Node);
Node = null;
}
}
void IGenerator.GetText(KeyScope scope, TextWriter writer)
{
writer.Write(Value);
}
}
}