Skip to content

Commit 3aec1d4

Browse files
committed
Add test for missing @partial-block ref #634
1 parent af5a7b9 commit 3aec1d4

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

handlebars/src/main/java/com/github/jknack/handlebars/Handlebars.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,8 @@ public Handlebars parentScopeResolution(final boolean parentScopeResolution) {
12541254
* <pre>
12551255
* {{> @partial-block}}
12561256
* </pre>
1257-
* Attention: If this is set to true, Handlebars works *much* slower!
1257+
* Attention: If this is set to true, Handlebars works *much* slower! while rendering
1258+
* partial blocks. Default is: true for compatibility reasons.
12581259
*
12591260
* @return If true partial blocks will be evaluated before the partial will be rendered
12601261
* to allow inline block side effects.
@@ -1271,7 +1272,8 @@ public boolean preEvaluatePartialBlocks() {
12711272
* <pre>
12721273
* {{> @partial-block}}
12731274
* </pre>
1274-
* Attention: If this is set to true, Handlebars works *much* slower!
1275+
* Attention: If this is set to true, Handlebars works *much* slower! while rendering
1276+
* partial blocks. Default is: true for compatibility reasons.
12751277
*
12761278
* @param preEvaluatePartialBlocks If true partial blocks will be evaluated before the
12771279
* partial will be rendered to allow inline block side
@@ -1290,7 +1292,8 @@ public void setPreEvaluatePartialBlocks(final boolean preEvaluatePartialBlocks)
12901292
* <pre>
12911293
* {{> @partial-block}}
12921294
* </pre>
1293-
* Attention: If this is set to true, Handlebars works *much* slower!
1295+
* Attention: If this is set to true, Handlebars works *much* slower! while rendering
1296+
* partial blocks. Default is: true for compatibility reasons.
12941297
*
12951298
* @param preEvaluatePartialBlocks If true partial blocks will be evaluated before the
12961299
* partial will be rendered to allow inline block side
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.github.jknack.handlebars.issues;
2+
3+
import com.github.jknack.handlebars.HandlebarsException;
4+
import com.github.jknack.handlebars.v4Test;
5+
import static org.junit.Assert.assertTrue;
6+
import static org.junit.Assert.fail;
7+
import org.junit.Test;
8+
9+
public class Issue634 extends v4Test {
10+
11+
@Test
12+
public void shouldThrowHandlebarsExceptionWhenPartialBlockIsMissing() throws Exception {
13+
try {
14+
shouldCompileTo("{{> my-partial}}",
15+
$("partials", $("my-partial", "Hello {{> @partial-block}}")), null);
16+
fail("Must throw HandlebarsException");
17+
} catch (HandlebarsException x) {
18+
assertTrue(x.getMessage().contains("does not provide a @partial-block"));
19+
}
20+
}
21+
22+
@Test
23+
public void shouldNotThrowHandlebarsException() throws Exception {
24+
shouldCompileTo("{{#> my-partial}}634{{/my-partial}}",
25+
$("partials", $("my-partial", "Hello {{> @partial-block}}")), "Hello 634");
26+
}
27+
28+
}

0 commit comments

Comments
 (0)