Skip to content

Commit

Permalink
Add test for missing @partial-block ref #634
Browse files Browse the repository at this point in the history
  • Loading branch information
jknack committed Jun 11, 2018
1 parent af5a7b9 commit 3aec1d4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,8 @@ public Handlebars parentScopeResolution(final boolean parentScopeResolution) {
* <pre>
* {{> @partial-block}}
* </pre>
* Attention: If this is set to true, Handlebars works *much* slower!
* Attention: If this is set to true, Handlebars works *much* slower! while rendering
* partial blocks. Default is: true for compatibility reasons.
*
* @return If true partial blocks will be evaluated before the partial will be rendered
* to allow inline block side effects.
Expand All @@ -1271,7 +1272,8 @@ public boolean preEvaluatePartialBlocks() {
* <pre>
* {{> @partial-block}}
* </pre>
* Attention: If this is set to true, Handlebars works *much* slower!
* Attention: If this is set to true, Handlebars works *much* slower! while rendering
* partial blocks. Default is: true for compatibility reasons.
*
* @param preEvaluatePartialBlocks If true partial blocks will be evaluated before the
* partial will be rendered to allow inline block side
Expand All @@ -1290,7 +1292,8 @@ public void setPreEvaluatePartialBlocks(final boolean preEvaluatePartialBlocks)
* <pre>
* {{> @partial-block}}
* </pre>
* Attention: If this is set to true, Handlebars works *much* slower!
* Attention: If this is set to true, Handlebars works *much* slower! while rendering
* partial blocks. Default is: true for compatibility reasons.
*
* @param preEvaluatePartialBlocks If true partial blocks will be evaluated before the
* partial will be rendered to allow inline block side
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.github.jknack.handlebars.issues;

import com.github.jknack.handlebars.HandlebarsException;
import com.github.jknack.handlebars.v4Test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Test;

public class Issue634 extends v4Test {

@Test
public void shouldThrowHandlebarsExceptionWhenPartialBlockIsMissing() throws Exception {
try {
shouldCompileTo("{{> my-partial}}",
$("partials", $("my-partial", "Hello {{> @partial-block}}")), null);
fail("Must throw HandlebarsException");
} catch (HandlebarsException x) {
assertTrue(x.getMessage().contains("does not provide a @partial-block"));
}
}

@Test
public void shouldNotThrowHandlebarsException() throws Exception {
shouldCompileTo("{{#> my-partial}}634{{/my-partial}}",
$("partials", $("my-partial", "Hello {{> @partial-block}}")), "Hello 634");
}

}

0 comments on commit 3aec1d4

Please sign in to comment.