Skip to content

LiquidHTMLSyntaxError false positive with dynamic html tag #1155

Description

@timmw

The @shopify/liquid-html-parser package throws LiquidHTMLSyntaxError for the following code:

<{% if true %}div{% endif %}></{% if true %}div{% endif %}>

Full error:

SyntaxError: expected a letter, "{{", "wbr" (case-insensitive), "track" (case-insensitive), "source" (case-insensitive), "param" (case-insensitive), "meta" (case-insensitive), "link" (case-insensitive), "keygen" (case-insensitive), "input" (case-insensitive), "img" (case-insensitive), "hr" (case-insensitive), "embed" (case-insensitive), "command" (case-insensitive), "col" (case-insensitive), "br" (case-insensitive), "base" (case-insensitive), "area" (case-insensitive), "svg", "style", or "script"

I'd expect this syntax to be supported rather than throwing an error.

This syntax existed in older versions of the Dawn theme (example), although the theme has now been changed to work around it. This is how the issue presents in the theme editor:

Image

Reproducible with:

  • Shopify theme editor
  • Programmatic use of @shopify/liquid-html-parser

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions