Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 22, 2025

This PR adds support for the # inline comment tag, as introduced in Shopify's Liquid PR #1498. This provides a simpler syntax for adding single-line comments without requiring an end tag.

New Syntax

{% # This is an inline comment %}

The inline comment tag supports whitespace trimming like other Liquid tags:

{%- # trimmed comment -%}

Examples

Basic usage:

Hello {% # this is a comment %} World

Output: Hello World

With whitespace trimming:

Hello{%- # comment -%}World

Output: HelloWorld

In templates:

{% # Start of section %}
{% assign name = 'John' %}
{% # Output the greeting %}
Hello {{ name }}!
{% # End of section %}

Output: Hello John!

Between control structures:

{% if true %}
  {% # This comment won't appear in output %}
  Success
{% endif %}

Output: Success

Implementation Details

  • Reuses the existing CommentStatement AST node for consistency
  • Modified tag parsing to handle # as a special character (not a valid identifier)
  • Follows the same patterns as other inline tags like echo, break, and continue
  • Supports whitespace trimming (-) markers like other Liquid tags

Testing

Added comprehensive test coverage:

  • 4 parser tests to verify correct AST generation
  • 6 template rendering tests to verify comments don't produce output
  • All 1,201 tests pass with no regressions
  • CodeQL security analysis passed with 0 alerts

Fixes the issue requesting support for the # comment tag as referenced in the Shopify Liquid enhancement.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/Shopify/liquid/pulls/1498
    • Triggering command: curl -s REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Add support for # tag</issue_title>
<issue_description>> This PR adds a new tag named # that behaves like a comment.

Shopify/liquid#1498</issue_description>

<agent_instructions>Looked at the example in the referenced PR Shopify/liquid#1498
Add unit tests matching the comment tag.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@sebastienros It's not done, if you think you could give it a try that would be great. Personally, I am more focused on pre-compilation and breaking changes for the next major release.

Fixes #493


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add support for # tag with unit tests Add support for # inline comment tag Oct 23, 2025
Copilot AI requested a review from sebastienros October 23, 2025 00:01
@sebastienros sebastienros marked this pull request as ready for review October 23, 2025 00:07
@sebastienros sebastienros merged commit 5551c84 into main Oct 23, 2025
3 checks passed
@sebastienros sebastienros deleted the copilot/add-support-for-comment-tag branch October 23, 2025 00:08
@MihaxXx
Copy link
Contributor

MihaxXx commented Oct 23, 2025

These changes allow # style comments in standard tags, e.g.:

{% # this is a comment %}

Remaining issue:

Inside {% liquid %} blocks, lines starting with # are still not treated as comments. Instead, the parser skips the following statements.

Example:

{% liquid
  assign name = 'John'
  # very important information
  assign name = 'Jenna'
  echo name
%}

Observed behavior:

assign name = 'Jenna' is skipped because the parser treats the # line incorrectly.

Expected behavior:

Lines starting with # inside {% liquid %} should be treated as comments. All other statements should execute normally.

Goal:
Extend the parser so that both {% # comment %} and inline # comments inside {% liquid %} blocks are fully supported, aligning with standard Liquid behavior.

The example from the initial description:

{% liquid
  # required args:
  assign product = product

  # optional args:
  assign should_show_border = should_show_border | default: true
  assign should_show_cursor = should_show_cursor | default: true
%}

@copilot can you take a look and prepare a PR to fix this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for # tag

3 participants