Skip to content

Twig parser breaks files with '{#' in strings in 2.8.1 #880

@Lustmored

Description

@Lustmored

I have a template (Extending other) with the following translated message in a block, in ICU message format:

{{ '{visited, plural, =0 {Nobody visited this room yet} one {1 person visited this room} other {# people visited this room} }'|trans({ 'visited': 6 }) }}

Twig components update 2.8.1 broke the template with linter error:

A template that extends another one cannot include content outside Twig blocks. Did you forget to put the content inside a {% block %} tag?

I have narrowed it down to {# existing in a string in a template - looks like some code comments removing code got bugged. Changing the string to:

{{ '{visited, plural, =0 {Nobody visited this room yet} one {1 person visited this room} other { # people visited this room} }'|trans({ 'visited': 6 }) }}
or
{{ "{visited, plural, =0 {Nobody visited this room yet} one {1 person visited this room} other {\# people visited this room} }"|trans({ 'visited': 6 }) }}

resolves the issue, but it definitely is an unexpected regression.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions