Skip to content

Commit 51cb337

Browse files
author
Sam Pullara
committed
Merge pull request spullara#41 from gw0/bug-subblockcaching
Added inheritance test with sub block replacement that fails while caching
2 parents 20f2fe3 + 0f898ab commit 51cb337

6 files changed

Lines changed: 41 additions & 1 deletion

File tree

compiler/src/test/java/com/github/mustachejava/ExtensionTest.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,29 @@ public void testParentReplace() throws MustacheException, IOException, Execution
6262
MustacheFactory c = new DefaultMustacheFactory(root);
6363
Mustache m = c.compile("replace.html");
6464
StringWriter sw = new StringWriter();
65-
m.execute(sw, new Object() { String replace = "true"; });
65+
m.execute(sw, new Object() { String replace = "false"; });
6666
assertEquals(getContents(root, "replace.txt"), sw.toString());
6767
}
6868

69+
@Test
70+
public void testSubBlockCaching() throws MustacheException, IOException, ExecutionException, InterruptedException {
71+
MustacheFactory c = new DefaultMustacheFactory(root);
72+
Mustache m = c.compile("subblockchild1.html");
73+
StringWriter sw = new StringWriter();
74+
m.execute(sw, new Object() {});
75+
assertEquals(getContents(root, "subblockchild1.txt"), sw.toString());
76+
77+
m = c.compile("subblockchild2.html");
78+
sw = new StringWriter();
79+
m.execute(sw, new Object() {});
80+
assertEquals(getContents(root, "subblockchild2.txt"), sw.toString());
81+
82+
m = c.compile("subblockchild1.html");
83+
sw = new StringWriter();
84+
m.execute(sw, new Object() {});
85+
assertEquals(getContents(root, "subblockchild1.txt"), sw.toString());
86+
}
87+
6988
@Test
7089
public void testSubSub() throws MustacheException, IOException, ExecutionException, InterruptedException {
7190
MustacheFactory c = new DefaultMustacheFactory(root);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{{<subblocksuper}}
2+
3+
{{$content}}
4+
first
5+
{{/content}}
6+
7+
{{/subblocksuper}}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
first
2+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{{<subblocksuper}}
2+
3+
{{$content}}
4+
second
5+
{{/content}}
6+
7+
{{/subblocksuper}}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
second
2+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{$base}}
2+
{{$content}}{{/content}}
3+
{{/base}}

0 commit comments

Comments
 (0)