Fix Bug with inline tags in compound tags

Whenever there was an inline tag in a compound tag, it would consume one
too many chunks.
This commit is contained in:
Travis Parks 2013-07-22 22:25:13 -04:00
parent d7a0ab3b38
commit 65b79062d6
4 changed files with 46 additions and 6 deletions

View File

@ -1004,6 +1004,47 @@ Last";
Assert.AreEqual(expected, result, "The wrong text was generated.");
}
/// <summary>
///
/// </summary>
[TestMethod]
public void TestCompile_Each_LoopOverCollectionTwice()
{
List<TestObject> objects = new List<TestObject>();
objects.Add(new TestObject { Name = "name1", Val = "val1" });
objects.Add(new TestObject { Name = "name2", Val = "val2" });
objects.Add(new TestObject { Name = "name3", Val = "val3" });
const string template = @"{{#each this}}
Item Number: {{#index}}<br />
{{/each}}
{{#each this}}
Item Number: foo<br />
{{/each}}";
FormatCompiler compiler = new FormatCompiler();
Generator generator = compiler.Compile(template);
string actual = generator.Render(objects);
const string expected = @"Item Number: 0<br />
Item Number: 1<br />
Item Number: 2<br />
Item Number: foo<br />
Item Number: foo<br />
Item Number: foo<br />
";
Assert.AreEqual(expected, actual, "The wrong text was found.");
}
public class TestObject
{
public String Name { get; set; }
public String Val { get; set; }
}
#endregion
#region With

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.1.2.0")]
[assembly: AssemblyFileVersion("0.1.2.0")]
[assembly: AssemblyVersion("0.1.3.0")]
[assembly: AssemblyFileVersion("0.1.3.0")]

View File

@ -237,8 +237,7 @@ namespace Mustache
else
{
generator.AddStaticGenerators(trimmer.RecordText(leading, true, true));
Match nextMatch = findNextTag(nextDefinition, format, formatIndex);
ArgumentCollection arguments = getArguments(nextDefinition, nextMatch);
ArgumentCollection arguments = getArguments(nextDefinition, match);
InlineGenerator inlineGenerator = new InlineGenerator(nextDefinition, arguments);
generator.AddGenerator(inlineGenerator);
}

View File

@ -34,6 +34,6 @@ using System.Runtime.CompilerServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.2.0")]
[assembly: AssemblyFileVersion("0.1.2.0")]
[assembly: AssemblyVersion("0.1.3.0")]
[assembly: AssemblyFileVersion("0.1.3.0")]
[assembly: InternalsVisibleTo("mustache-sharp.test")]