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", 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, Scope contextScope) { if (contextScope.TryFind("index", out object index)) { writer.Write(index); } } } }