Resolves issue 7 regarding proper handling of nested contexts when processing a

nested context.
This commit is contained in:
Michael Bayne
2011-05-26 14:52:45 -07:00
parent 31d0a0985d
commit ef971015bd
3 changed files with 34 additions and 13 deletions
@@ -134,6 +134,21 @@ public class MustacheTest
}), "foo inside:foo nonfoo foo", "{{bar}} {{>foo}} {{>baz}} {{bar}}", context("bar", "foo"));
}
@Test public void testPartialPlusNestedContext () {
test(Mustache.compiler().withLoader(new Mustache.TemplateLoader() {
public Reader getTemplate (String name) {
if (name.equals("nested")) {
return new StringReader("{{name}}{{thing_name}}");
} else {
return new StringReader("nonfoo");
}
}
}), "foo((foobar)(foobaz))", "{{name}}({{#things}}({{>nested}}){{/things}})",
context("name", "foo",
"things", Arrays.asList(context("thing_name", "bar"),
context("thing_name", "baz"))));
}
@Test public void testDelimiterChange () {
test("foo bar baz", "{{one}} {{=<% %>=}}<%two%><%={{ }}=%> {{three}}",
context("one", "foo", "two", "bar", "three", "baz"));