Add a test for recursive partial expansion.

This pertains to issue #124, but it seems to work fine.
This commit is contained in:
Michael Bayne
2020-11-03 11:15:00 -08:00
parent 9855710cc0
commit 9508731dfa
@@ -243,6 +243,24 @@ public abstract class SharedTests extends GWTTestCase
context("thing_name", "baz")))); context("thing_name", "baz"))));
} }
@Test public void testRecursivePartial () {
String template = "[{{name}}{{#properties}}, {{> schema.mustache}}{{/properties}}]";
test(Mustache.compiler().withLoader(new Mustache.TemplateLoader() {
public Reader getTemplate (String name) {
return new StringReader(template);
}
}), "[level0, [level1a, [level2a]], [level1b, [level2b]]]", template,
context("name", "level0",
"properties", Arrays.asList(
context("name", "level1a",
// test with empty list as recursive terminator
"properties", context("name", "level2a", "properties", Arrays.asList())),
context("name", "level1b",
// test with null as recursive terminator
"properties", context("name", "level2b", "properties", null))
)));
}
@Test public void testDelimiterChange () { @Test public void testDelimiterChange () {
test("foo bar baz", "{{one}} {{=<% %>=}}<%two%><%={{ }}=%> {{three}}", test("foo bar baz", "{{one}} {{=<% %>=}}<%two%><%={{ }}=%> {{three}}",
context("one", "foo", "two", "bar", "three", "baz")); context("one", "foo", "two", "bar", "three", "baz"));