-
-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inline partials leak from block context to global context fix #523
- Loading branch information
Showing
3 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
handlebars/src/test/java/com/github/jknack/handlebars/issues/Hbs523.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.github.jknack.handlebars.issues; | ||
|
||
import java.io.IOException; | ||
|
||
import org.junit.Test; | ||
|
||
import com.github.jknack.handlebars.Handlebars; | ||
import com.github.jknack.handlebars.v4Test; | ||
|
||
public class Hbs523 extends v4Test { | ||
|
||
@Override | ||
protected void configure(final Handlebars handlebars) { | ||
super.configure(handlebars); | ||
handlebars.deletePartialAfterMerge(true); | ||
} | ||
@Test | ||
public void shouldCallPartialWithoutSideEffect() throws IOException { | ||
String base = "text from base partial<br>\n" + | ||
"{{#> inlinePartial}}{{/inlinePartial}}<br>"; | ||
String inherit1 = "inherit1<br>\n" + | ||
"{{#>base}}\n" + | ||
"{{#*inline \"inlinePartial\"}}\n" + | ||
"inline partial defined by inherit1, called from base\n" + | ||
"{{/inline}}\n" + | ||
"{{/base}}"; | ||
String inherit2 = "inherit2<br>\n" + | ||
"{{#>base}}\n" + | ||
"{{/base}}"; | ||
String main = "main has partials:<br>\n" + | ||
"-------------<br>\n" + | ||
"{{>inherit1}}\n" + | ||
"-------------<br>\n" + | ||
"{{>inherit2}}"; | ||
|
||
shouldCompileTo(main, | ||
$("partials", $("base", base, "inherit1", inherit1, "inherit2", inherit2)), | ||
"main has partials:<br>\n" + | ||
"-------------<br>\n" + | ||
"inherit1<br>\n" + | ||
"text from base partial<br>\n" + | ||
"\n" + | ||
"inline partial defined by inherit1, called from base\n" + | ||
"<br>\n" + | ||
"-------------<br>\n" + | ||
"inherit2<br>\n" + | ||
"text from base partial<br>\n" + | ||
"<br>"); | ||
} | ||
|
||
} |