Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix parsing comment tag with extra string #1769

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

ggmichaelgo
Copy link
Contributor

What are you trying to solve?

#1755 introduced a bug in comment tag that prevents the tag from having extra string inside.

With the bug, this valid template fails to be parsed

{%comment}{% assign a = 1 %}
  {% if true %}
{%endcomment}{% endif %}

@peterzhu2118
Copy link
Member

I'm confused about the example template. Is {%comment} valid opening for a comment? Is {%endcomment} a valid closing? What's the {% endif %} supposed to close?

@ggmichaelgo
Copy link
Contributor Author

ggmichaelgo commented Dec 12, 2023

I'm confused about the example template. Is {%comment} valid opening for a comment? Is {%endcomment} a valid closing? What's the {% endif %} supposed to close?

{%endcomment}{% endif %} is the comment tag delimiter.

With Liquid 5.4.0, you can see how the comment tag used to get parsed.

require 'liquid'

template = Liquid::Template.parse("{%comment}{% assign a = 1 %}{%endcomment}{% endif %}")
pp template.root.nodelist[0]

Copy link
Member

@peterzhu2118 peterzhu2118 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR makes sense. However, I'm not a fan that this is valid Liquid syntax because it's confusing and hard to understand. Do we have a plan to deprecate or drop support for weird syntax like this?

@ggmichaelgo
Copy link
Contributor Author

I agree that example Liquid template is awful to read, and I wish we could deprecate some Liquid syntaxes...
However, we can't deprecate this syntax pattern on Liquid because we can't break existing Shopify themes...

@ggmichaelgo ggmichaelgo merged commit c658bf9 into main Dec 13, 2023
9 checks passed
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.

2 participants