using System;
using System.Collections.Generic;
using System.IO;
namespace Mustache
{
///
/// Generates the text for a tag that is replaced with its generated text.
///
internal sealed class InlineGenerator : IGenerator
{
private readonly TagDefinition _definition;
private readonly ArgumentCollection _arguments;
///
/// Initializes a new instance of an InlineGenerator.
///
/// The tag to render the text for.
/// The arguments passed to the tag.
public InlineGenerator(TagDefinition definition, ArgumentCollection arguments)
{
_definition = definition;
_arguments = arguments;
}
void IGenerator.GetText(Scope scope, TextWriter writer, Scope context)
{
Dictionary arguments;
if (_definition.IsSetter)
{
arguments = _arguments.GetArguments();
}
else
{
arguments = _arguments.GetArguments(scope, context);
}
_definition.GetText(writer, arguments, context);
}
}
}