liquid icon indicating copy to clipboard operation
liquid copied to clipboard

Nested `comment` blocks

Open jg-rp opened this issue 1 year ago • 1 comments

This PR adds a new implementation of the comment tag that allows nested comment blocks.

This new comment tag is enabled by default when using liquid.future.Environment, and can optionally be registered with liquid.Environment by importing NestedCommentTextTag from liquid.builtin.tags.comment_tag.

We do not support comments containing unclosed output statements ({{ without a }}) or unclosed tags ({% without a %}), which Shopify/Liquid does.

jg-rp avatar Dec 14 '23 08:12 jg-rp

This is going to require more thought. Contrary to what the Python Liquid docs say, we are parsing text between comment tags, and we do raise a syntax error for templates such as:

{% comment %}
  {% assign foo = "1"
{% endcomment %}

Nested comment blocks alone are not enough. We need to match Shopify/Liquid more closely, which will required changes to Python Liquid's lexer.

jg-rp avatar Dec 14 '23 08:12 jg-rp