MustacheSharp/mustache-sharp/InlineGenerator.cs

32 lines
1.1 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
namespace mustache
{
/// <summary>
/// Generates the text for a tag that only exists on a single line.
/// </summary>
internal sealed class InlineGenerator : IGenerator
{
private readonly TagDefinition _definition;
private readonly ArgumentCollection _arguments;
/// <summary>
/// Initializes a new instance of an InlineGenerator.
/// </summary>
/// <param name="definition">The tag to render the text for.</param>
/// <param name="arguments">The arguments passed to the tag.</param>
public InlineGenerator(TagDefinition definition, ArgumentCollection arguments)
{
_definition = definition;
_arguments = arguments;
}
string IGenerator.GetText(IFormatProvider provider, KeyScope scope)
{
Dictionary<string, object> arguments = _arguments.GetArguments(scope);
return _definition.Decorate(provider, String.Empty, arguments);
}
}
}