Skip to content

Commit 4773a5b

Browse files
committed
Inline partials "leak" - another scenario fix #539
1 parent efd7149 commit 4773a5b

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

  • handlebars/src/test/java/com/github/jknack/handlebars/issues
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.github.jknack.handlebars.issues;
2+
3+
import com.github.jknack.handlebars.Handlebars;
4+
import com.github.jknack.handlebars.v4Test;
5+
import org.junit.Test;
6+
7+
public class Issue539 extends v4Test {
8+
9+
@Override protected void configure(Handlebars handlebars) {
10+
super.configure(handlebars);
11+
handlebars.setPreEvaluatePartialBlocks(false);
12+
}
13+
14+
@Test
15+
public void inlinePartialsLeak() throws Exception {
16+
shouldCompileTo("main has partials:<br>\n"
17+
+ "-------------<br>\n"
18+
+ "{{>inherit1}}\n"
19+
+ "-------------<br>\n"
20+
+ "{{>inherit2}}",
21+
$("hash", $,
22+
"partials",
23+
$(
24+
"base", "text from base partial<br>\n"
25+
+ "{{#>inlinePartial}}{{/inlinePartial}}<br>\n"
26+
+ "{{#>inlinePartial2}}{{/inlinePartial2}}<br>",
27+
"inherit1", "inherit1<br>\n"
28+
+ "{{#>base}}\n"
29+
+ "{{#*inline \"inlinePartial\"}}\n"
30+
+ " inline partial defined by inherit1, called from base\n"
31+
+ "{{/inline}}\n"
32+
+ " {{#*inline \"inlinePartial2\"}}\n"
33+
+ " {{>some-other-template}}\n"
34+
+ " {{/inline}}\n"
35+
+ "{{/base}}",
36+
"inherit2", "inherit2<br>\n"
37+
+ "{{#>base}}\n"
38+
+ "{{/base}}",
39+
"some-other-template", "template called from second inline partial of inherit 1")
40+
),
41+
"main has partials:<br>\n"
42+
+ "-------------<br>\n"
43+
+ "inherit1<br>\n"
44+
+ "text from base partial<br>\n"
45+
+ "<br>\n"
46+
+ "<br>\n"
47+
+ "-------------<br>\n"
48+
+ "inherit2<br>\n"
49+
+ "text from base partial<br>\n"
50+
+ "<br>\n"
51+
+ "<br>");
52+
}
53+
}

0 commit comments

Comments
 (0)