Skip to content

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

Description

@JonMcPherson

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions