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