Shopify / Shopify/liquid

Don't throw syntax errors in {% comment %} blocks

Open
#1,694 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
11.9k
Forks
1.5k
Avg merge
17h 55m
Merged PRs (30d)
3

Description

This is a bit of an opinion piece, but I don't think we should be throwing syntax errors for liquid in a comment block. A use case for comments is excluding code that you don't want to run—this means it may be incomplete and not working. I think this was already considered to a degree since there's an escape hatch for tags that aren't registered (via unknown_tag overwrite). For example:

This will successfully parse:

{% comment %}
  {% not_a_valid_tag %}
{% endcomment %}

This will throw a syntax error:

{% comment %}
  {% cycle %}
{% endcomment %}

I believe both of these should parse without error.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining how the parser handles {% comment %} blocks and how unknown_tag and cycle tags are validated. Reproduce the two Liquid examples from the issue, then verify that both incomplete and registered-but-invalid tags inside comments parse without syntax errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.