Skip to content

Template literals cause syntax error inside {% javascript %} Liquid tag #2042

@1TheNeo1

Description

@1TheNeo1

Description

Using JavaScript template literals (backticks) inside Shopify’s {% javascript %} Liquid tag
causes a syntax/parsing error. The same code works correctly when rewritten using
string concatenation.

This appears to be a Liquid parsing issue rather than a JavaScript syntax problem.

Failing example

{% javascript %}
this._inner.style.transform = `translate3d(${this._x}px,0,0)`;
{% endjavascript %}

Error

Error is a bit strange, in scripts it fails at parsing all section javascripts into a single scripts.js file:
Image

Additional context

This parsing error only reproduces when the JavaScript is defined inside a
Custom Element (HTMLElement subclass). When similar code is placed outside
of a Custom Element, the {% javascript %} tag does not throw an error.

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