Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escaping expressions (ESC_VAR) does not work for raw vars or any custom delimiter #1084

Open
JonMcPherson opened this issue Nov 29, 2023 · 0 comments

Comments

@JonMcPherson
Copy link

JonMcPherson commented Nov 29, 2023

The ESC_VAR lexer function which supports escaped handlebars expressions using a backslash, only works for normal expressions that are defined using 2 curly brackets like \{{var}}, but it does not work for raw expressions \{{{rawVar}}}, or any custom delimiters \[[var]], giving a false syntax error:

com.github.jknack.handlebars.HandlebarsException: inline@f73de56:1:1: found: '\'
\{{{foo}}}
 ^

If you add these test cases to the Issue #294 test suite (original support for escaped vars), then you should see this error. This is a bug since it should be supported according the Handlebars spec.

@Test
public void escapeRawVars() throws IOException {
  shouldCompileTo("\\{{{foo}}}", $, "{{{foo}}}");
}

@Test
public void escapeRawVarsWithText() throws IOException {
  shouldCompileTo("before \\{{{foo}}} after", $, "before {{{foo}}} after");
}

I've added support in this PR #1085

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant