liquid
liquid copied to clipboard
Nested `comment` blocks
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.
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.