mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Merge pull request #1731 from Shopify/allow-recursive-liquid-tags
Allow liquid tag inside liquid tag
This commit is contained in:
@@ -45,6 +45,12 @@ module Liquid
|
|||||||
end
|
end
|
||||||
tag_name = Regexp.last_match(1)
|
tag_name = Regexp.last_match(1)
|
||||||
markup = Regexp.last_match(2)
|
markup = Regexp.last_match(2)
|
||||||
|
|
||||||
|
if tag_name == 'liquid'
|
||||||
|
parse_context.line_number -= 1
|
||||||
|
next parse_liquid_tag(markup, parse_context)
|
||||||
|
end
|
||||||
|
|
||||||
unless (tag = registered_tags[tag_name])
|
unless (tag = registered_tags[tag_name])
|
||||||
# end parsing if we reach an unknown tag and let the caller decide
|
# end parsing if we reach an unknown tag and let the caller decide
|
||||||
# determine how to proceed
|
# determine how to proceed
|
||||||
|
|||||||
@@ -113,4 +113,37 @@ class LiquidTagTest < Minitest::Test
|
|||||||
{% raw %}{% liquid echo 'test' %}{% endraw %}
|
{% raw %}{% liquid echo 'test' %}{% endraw %}
|
||||||
LIQUID
|
LIQUID
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_nested_liquid_tags
|
||||||
|
assert_template_result('good', <<~LIQUID)
|
||||||
|
{%- liquid
|
||||||
|
liquid
|
||||||
|
if true
|
||||||
|
echo "good"
|
||||||
|
endif
|
||||||
|
-%}
|
||||||
|
LIQUID
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_nested_liquid_tags_on_same_line
|
||||||
|
assert_template_result('good', <<~LIQUID)
|
||||||
|
{%- liquid liquid liquid echo "good" -%}
|
||||||
|
LIQUID
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_nested_liquid_liquid_is_not_skipped_if_used_in_non_tag_position
|
||||||
|
assert_template_result('liquid', <<~LIQUID, { 'liquid' => 'liquid' })
|
||||||
|
{%- liquid liquid liquid echo liquid -%}
|
||||||
|
LIQUID
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_next_liquid_with_unclosed_if_tag
|
||||||
|
assert_match_syntax_error("Liquid syntax error (line 2): 'if' tag was never closed", <<~LIQUID)
|
||||||
|
{%- liquid
|
||||||
|
liquid if true
|
||||||
|
echo "good"
|
||||||
|
endif
|
||||||
|
-%}
|
||||||
|
LIQUID
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user