mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-03 09:05:13 -07:00
Improve disabled tag error output
This commit is contained in:
@@ -26,4 +26,4 @@
|
|||||||
argument:
|
argument:
|
||||||
include: "Argument error in tag 'include' - Illegal template name"
|
include: "Argument error in tag 'include' - Illegal template name"
|
||||||
disabled:
|
disabled:
|
||||||
tag: "usage has been disabled in this context."
|
tag: "usage is not allowed in this context"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
module Liquid
|
module Liquid
|
||||||
class Render < Tag
|
class Render < Tag
|
||||||
SYNTAX = /(#{QuotedString})#{QuotedFragment}*/o
|
SYNTAX = /(#{QuotedString})#{QuotedFragment}*/o
|
||||||
DISABLED_TAGS = %w(include)
|
DISABLED_TAGS = %w(include).freeze
|
||||||
|
|
||||||
attr_reader :template_name_expr, :attributes
|
attr_reader :template_name_expr, :attributes
|
||||||
|
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ class DisabledTagsTest < Minitest::Test
|
|||||||
|
|
||||||
def test_disables_raw
|
def test_disables_raw
|
||||||
with_custom_tag('disable', DisableRaw) do
|
with_custom_tag('disable', DisableRaw) do
|
||||||
assert_template_result 'raw usage has been disabled in this context.foo', '{% disable %}{% raw %}Foobar{% endraw %}{% echo "foo" %}{% enddisable %}'
|
assert_template_result 'raw usage is not allowed in this contextfoo', '{% disable %}{% raw %}Foobar{% endraw %}{% echo "foo" %}{% enddisable %}'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_disables_echo_and_raw
|
def test_disables_echo_and_raw
|
||||||
with_custom_tag('disable', DisableRawEcho) do
|
with_custom_tag('disable', DisableRawEcho) do
|
||||||
assert_template_result 'raw usage has been disabled in this context.echo usage has been disabled in this context.', '{% disable %}{% raw %}Foobar{% endraw %}{% echo "foo" %}{% enddisable %}'
|
assert_template_result 'raw usage is not allowed in this contextecho usage is not allowed in this context', '{% disable %}{% raw %}Foobar{% endraw %}{% echo "foo" %}{% enddisable %}'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ class RenderTagTest < Minitest::Test
|
|||||||
'test_include' => '{% include "foo" %}'
|
'test_include' => '{% include "foo" %}'
|
||||||
)
|
)
|
||||||
|
|
||||||
assert_template_result 'include usage has been disabled in this context.', '{% render "test_include" %}'
|
assert_template_result 'include usage is not allowed in this context', '{% render "test_include" %}'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_includes_will_not_render_inside_nested_sibling_tags
|
def test_includes_will_not_render_inside_nested_sibling_tags
|
||||||
@@ -163,6 +163,6 @@ class RenderTagTest < Minitest::Test
|
|||||||
'test_include' => '{% include "foo" %}'
|
'test_include' => '{% include "foo" %}'
|
||||||
)
|
)
|
||||||
|
|
||||||
assert_template_result 'include usage has been disabled in this context.include usage has been disabled in this context.', '{% render "nested_render_with_sibling_include" %}'
|
assert_template_result 'include usage is not allowed in this contextinclude usage is not allowed in this context', '{% render "nested_render_with_sibling_include" %}'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user