Skip to content

Parser fails on inline JavaScript comments #1250

@axadrn

Description

@axadrn

The templ parser throws an error when JavaScript code inside a <script> tag has an inline comment.

Steps to Reproduce

templ ScriptExample() {
    <script>
        const category = path.split('/')[2]; // example comment
    </script>
}

Actual Behavior

parsing error: template closing brace not found

Workaround

Moving the comment to its own line resolves the issue:

templ ScriptExample() {
    <script>
        // example comment
        const category = path.split('/')[2];
    </script>
}

Environment

  • templ version: v0.3.943

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