4
0
mirror of https://github.com/art-ist/mustache-sharp.git synced 2024-06-16 21:05:32 +00:00
MustacheSharp/mustache-sharp/CompoundGenerator.cs
Travis Parks f8628aaf86 Implement custom tags.
This is the first step towards supporting custom tags. There are
wrinkles I need to work out, since I'm not 100% sure what the finished
code will look like.
2013-01-08 21:33:53 -05:00

33 lines
885 B
C#

using System;
using System.Collections.Generic;
using System.Text;
namespace mustache
{
internal sealed class CompoundGenerator : IGenerator
{
private readonly List<IGenerator> _generators;
public CompoundGenerator()
{
_generators = new List<IGenerator>();
}
public void AddGenerator(StaticGenerator generator)
{
_generators.Add(generator);
}
string IGenerator.GetText(object source)
{
StringBuilder builder = new StringBuilder();
foreach (IGenerator generator in _generators)
{
builder.Append(generator.GetText(source));
}
string innerText = builder.ToString();
// TODO - process with tag's custom handler
return innerText;
}
}
}