MustacheSharp/MustacheSharp/StaticGenerator.cs

37 lines
900 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
{
/// <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)
{
2018-07-15 22:57:30 +00:00
Value = value.Replace(Environment.NewLine, String.Empty);
2014-05-21 17:38:39 +00:00
}
else
{
2018-07-15 22:57:30 +00:00
Value = value;
2014-05-21 17:38:39 +00:00
}
}
/// <summary>
/// Gets or sets the static text.
/// </summary>
2018-07-15 22:57:30 +00:00
public string Value { get; }
2016-03-21 17:41:46 +00:00
void IGenerator.GetText(TextWriter writer, Scope scope, Scope context, Action<Substitution> postProcessor)
{
writer.Write(Value);
}
}
}