Fixed some bugs with newline skipping. Improved error handling when a tag is

not closed properly and another tag follows it on the same line. Added support
for -first and -last special variables. Fixed problem with resolving outermost
component of a compound key in parent contexts.
This commit is contained in:
Michael Bayne
2010-10-22 05:02:09 +00:00
parent 5932123d79
commit 0b9b01dab6
3 changed files with 90 additions and 29 deletions
@@ -178,6 +178,16 @@ public class MustacheTest
"things", Arrays.asList(context("name", "bar"), context("name", "baz"))));
}
@Test public void testFirst () {
test("foo|bar|baz", "{{#things}}{{^-first}}|{{/-first}}{{this}}{{/things}}",
context("things", Arrays.asList("foo", "bar", "baz")));
}
@Test public void testLast () {
test("foo|bar|baz", "{{#things}}{{this}}{{^-last}}|{{/-last}}{{/things}}",
context("things", Arrays.asList("foo", "bar", "baz")));
}
protected void test (String expected, String template, Object ctx)
{
assertEquals(expected, Mustache.compiler().compile(template).execute(ctx));