Fixed bug where -last was not correctly handled on lists of a single element,

where said element is both -first and -last.
This commit is contained in:
Michael Bayne
2011-08-29 13:51:11 -07:00
parent 28978548c5
commit a3eb9e22e1
3 changed files with 22 additions and 18 deletions
@@ -329,6 +329,13 @@ public class MustacheTest
context("things", Arrays.asList("foo", "bar", "baz")));
}
@Test public void testFirstLast () {
test("[foo]", "{{#things}}{{#-first}}[{{/-first}}{{this}}{{#-last}}]{{/-last}}{{/things}}",
context("things", Arrays.asList("foo")));
test("foo", "{{#things}}{{this}}{{^-last}}|{{/-last}}{{/things}}",
context("things", Arrays.asList("foo")));
}
@Test public void testIndex () {
test("123", "{{#things}}{{-index}}{{/things}}",
context("things", Arrays.asList("foo", "bar", "baz")));