Skip to content

Bug when using triple starting braces. #896

@sanketdhoble

Description

@sanketdhoble

For the below invalid syntax with triple brackets:
"Hey {{{data.variables.aa | default('there') }}"

data = { variables: {} }

I get output as [object][object] instead of getting syntax error. Why twig didn't throw it as an invalid syntax?

FYI: for input with starting & closing 3 braces : "Hey {{{data.variables.aa | default('there') }}}" I get output: "Hey [object][object]}"

Since I mistakenly added 3 braces, I expect to get an error instead of [object][object]

I used template.tokens to catch any twig syntax errors, but that didn't catch above error:

try {
    const template: any = Twig.twig({ data: startingString });
    if (template) {
        return template.tokens;
    }
} catch (err) {
    this.logger.error('Invalid twig syntax', startingString, err);
}

Any thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions