forked from jknack/handlebars.java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for escaping raw expressions (TVAR)
- Loading branch information
1 parent
ae4e84a
commit b3b7c7f
Showing
3 changed files
with
53 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
47 changes: 47 additions & 0 deletions
47
handlebars/src/test/java/com/github/jknack/handlebars/i1084/Issue1084.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,47 @@ | ||
package com.github.jknack.handlebars.i1084; | ||
|
||
import com.github.jknack.handlebars.AbstractTest; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class Issue1084 extends AbstractTest { | ||
|
||
@Test | ||
public void escapeRawVars() throws IOException { | ||
shouldCompileTo("\\{{{foo}}}", $, "{{{foo}}}"); | ||
} | ||
|
||
@Test | ||
public void escapeRawVarsWithText() throws IOException { | ||
shouldCompileTo("before \\{{{foo}}} after", $, "before {{{foo}}} after"); | ||
} | ||
|
||
@Test | ||
public void escapeRawVsUnescape() throws IOException { | ||
shouldCompileTo("\\{{{foo}}} {{{foo}}}", $("foo", "bar"), "{{{foo}}} bar"); | ||
} | ||
|
||
@Test | ||
public void escapeRawMultiline() throws IOException { | ||
shouldCompileTo("\\{{{foo\n}}}", $("foo", "bar"), "{{{foo\n}}}"); | ||
} | ||
|
||
@Test | ||
public void rawBlockEscape() throws IOException { | ||
shouldCompileTo("\\{{{#foo}}}", $("foo", "bar"), "{{{#foo}}}"); | ||
} | ||
|
||
@Test | ||
public void rawBlockEscapeWithParams() throws IOException { | ||
shouldCompileTo("\\{{{#foo x a x}}}", $("foo", "bar"), "{{{#foo x a x}}}"); | ||
} | ||
|
||
@Test | ||
public void escapeRawVarToText() throws IOException { | ||
assertEquals("\\{{{foo}}}", compile("\\{{{foo}}}").text()); | ||
} | ||
|
||
} |