Added support for "this" variable which refers to the context itself rather

than a member of the context.
This commit is contained in:
Michael Bayne
2010-10-21 21:28:06 +00:00
parent 3bad793de9
commit 134a22bcfd
2 changed files with 23 additions and 0 deletions
@@ -126,6 +126,15 @@ public class MustacheTest
context("bob}bob", "bar")));
}
@Test public void testTopLevelThis () {
assertEquals("bar", Mustache.compiler().compile("{{this}}").execute("bar"));
}
@Test public void testNestedThis () {
assertEquals("barbazbif", Mustache.compiler().compile("{{#things}}{{this}}{{/things}}").
execute(context("things", Arrays.asList("bar", "baz", "bif"))));
}
protected void test (String expected, String template, Object ctx)
{
assertEquals(expected, Mustache.compiler().compile(template).execute(ctx));