MustacheSharp/mustache-sharp/StaticGenerator.cs

42 lines
959 B
C#
Raw Normal View History

using System;
using System.IO;
namespace Mustache
{
/// <summary>
/// Generates a static block of text.
/// </summary>
internal sealed class StaticGenerator : IGenerator
{
private readonly string value;
/// <summary>
/// Initializes a new instance of a StaticGenerator.
/// </summary>
2014-05-21 17:38:39 +00:00
public StaticGenerator(string value, bool removeNewLines)
{
2014-05-21 17:38:39 +00:00
if (removeNewLines)
{
this.value = value.Replace(Environment.NewLine, String.Empty);
}
else
{
this.value = value;
}
}
/// <summary>
/// Gets or sets the static text.
/// </summary>
public string Value
{
get { return value; }
}
void IGenerator.GetText(Scope scope, TextWriter writer, Scope context)
{
writer.Write(Value);
}
}
}