Description
Right now comments in liquid are implemented through the {% comment %}
tag. Basically a block that doesn't do anything.
This has always been clunky and I think we should introduce syntax for this.
This is especially true because of the new liquid block tag. Consider that this is the only way to do inline comments right now:
{% liquid
comment Is the feature_image set?
endcomment
if product.featured_image
echo product.featured_image | img_tag
else
echo 'product-1'
endif
%}
Which... is bad.
My current thinking is that we should double down on our ruby heritage and designate #
as the comment character. Alternatives here would be c style //
or lua style --
This would transform the above to
{% liquid
# Is the feature_image set?
if product.featured_image
echo product.featured_image | img_tag
else
echo 'product-1'
endif
%}
Additionally we could introduce a new inline token for comments:
Single line comment {# comment #}
and multiline comments would be both supported
{#
First line
Second line
#}
The downside of this syntax is that it may cause collisions in existing liquid code. We can (but haven't) check the Shopify databases for how common this might be.
Activity