using System;
using System.Collections.Generic;
using System.IO;
namespace Mustache
{
///
/// Defines a tag that outputs the current index within an each loop.
///
internal sealed class IndexTagDefinition : InlineTagDefinition
{
///
/// Initializes a new instance of an IndexTagDefinition.
///
public IndexTagDefinition()
: base("index")
{
}
///
/// Gets whether the tag only exists within the scope of its parent.
///
protected override bool GetIsContextSensitive()
{
return true;
}
///
/// Gets the text to output.
///
/// The writer to write the output to.
/// The arguments passed to the tag.
/// Extra data passed along with the context.
public override void GetText(TextWriter writer, Dictionary arguments, object contextData)
{
int index = (int)contextData;
writer.Write(index);
}
}
}