Add ability for lambda to change the context for fragment execution

This commit is contained in:
robbytx
2014-03-13 19:38:54 -05:00
parent 3fe5e020d8
commit 75609b42df
2 changed files with 35 additions and 3 deletions
@@ -664,6 +664,20 @@ public class MustacheTest
}));
}
@Test public void testLambdaWithContext () {
test("a in l1, a in l2", "{{#l1}}{{a}}{{/l1}}, {{#l2}}{{a}}{{/l2}}",
context("l1", new Mustache.Lambda() {
public void execute(Template.Fragment frag, Writer out) throws IOException {
frag.execute(context("a", "a in l1"), out);
}
}, "l2", new Mustache.Lambda() {
public void execute(Template.Fragment frag, Writer out) throws IOException {
frag.execute(context("a", "a in l2"), out);
}
}
));
}
@Test public void testNonStandardDefaultDelims () {
test(Mustache.compiler().withDelims("<% %>"), "bar", "<%foo%>", new Object() {
String foo = "bar";