-
-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
raw-helper inside conditional results in Exception fix #519
- Loading branch information
Showing
4 changed files
with
38 additions
and
16 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,8 +70,6 @@ escape | |
text | ||
: | ||
TEXT | ||
| RAW_CONTENT | ||
| RAW_SPACE | ||
; | ||
|
||
spaces | ||
|
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
35 changes: 35 additions & 0 deletions
35
handlebars/src/test/java/com/github/jknack/handlebars/issues/Hbs519.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,35 @@ | ||
package com.github.jknack.handlebars.issues; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.io.IOException; | ||
|
||
import org.junit.Test; | ||
|
||
import com.github.jknack.handlebars.AbstractTest; | ||
import com.github.jknack.handlebars.Helper; | ||
import com.github.jknack.handlebars.Options; | ||
|
||
public class Hbs519 extends AbstractTest { | ||
|
||
@Test | ||
public void shouldCompileRawHelperStatementInsideConditional() throws IOException { | ||
shouldCompileTo("{{#unless test}}{{{{raw-helper}}}}{{testing}}{{{{/raw-helper}}}}{{/unless}}", | ||
$, $("raw-helper", new Helper<Object>() { | ||
|
||
@Override | ||
public Object apply(final Object context, final Options options) throws IOException { | ||
return options.fn(); | ||
} | ||
|
||
}), "{{testing}}"); | ||
} | ||
|
||
@Test | ||
public void shouldGetTextVersionOfRawHelperInsideConditional() throws IOException { | ||
assertEquals("{{#unless test}}{{{{raw-helper}}}}{{testing}}{{{{/raw-helper}}}}{{/unless}}", | ||
compile("{{#unless test}}{{{{raw-helper}}}}{{testing}}{{{{/raw-helper}}}}{{/unless}}") | ||
.text()); | ||
} | ||
|
||
} |