Skip to content

Using template string literal inside an @if gives parsing errors #2616

@jgerstle

Description

@jgerstle

Versions

Package Version

@angular-devkit/architect 0.2002.0
@angular-devkit/core 20.2.0
@angular-devkit/schematics 20.2.0
@angular/cli 20.2.0
@schematics/angular 20.2.0
typescript 5.9.2

Angular CLI: 20.2.0
Node: 20.19.4
Package Manager: npm 10.8.2
OS: linux x64
    

Angular: <error>

Package                      Version
------------------------------------
@angular-devkit/architect    0.2002.0
@angular-devkit/core         20.2.0
@angular-devkit/schematics   20.2.0
@angular/cli                 20.2.0
@schematics/angular          20.2.0
typescript                   5.9.2

when adding the following to my code and using the template parser it throws parsing errors: Parsing error: Unexpected character "EOF" (Do you have an unescaped "{" in your template? Use "{{ '{' }}") to escape it.)

code:

@Component({
  selector: 'demo-test-component',
  template: `
    @if (showContent) {
      <div>${DEMO_CONTENT}</div>
    }
  `
})
export class BugDemoComponent {
  showContent = true;
}

I have created a repo that reproduces the issue here: https://github.com/jgerstle/anuglar-template-parser-with-template-string-control-flow-bug

  • [ x ] I have updated to the latest supported version of the packages and checked my ng version output per the instructions given here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: template-parserESLint custom parser which enables linting Angular TemplatestriageThis issue needs to be looked at and categorized by a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions