From 5e9b0bd3e98581eda9a326c5737d8435818e3bda Mon Sep 17 00:00:00 2001 From: Mike Angell Date: Tue, 24 Sep 2019 09:05:22 +1000 Subject: [PATCH] Improve disabled tag error output --- lib/liquid/locales/en.yml | 2 +- lib/liquid/tags/render.rb | 2 +- test/integration/registers/disabled_tags_test.rb | 4 ++-- test/integration/tags/render_tag_test.rb | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/liquid/locales/en.yml b/lib/liquid/locales/en.yml index 9409b72..a26320b 100644 --- a/lib/liquid/locales/en.yml +++ b/lib/liquid/locales/en.yml @@ -26,4 +26,4 @@ argument: include: "Argument error in tag 'include' - Illegal template name" disabled: - tag: "usage has been disabled in this context." + tag: "usage is not allowed in this context" diff --git a/lib/liquid/tags/render.rb b/lib/liquid/tags/render.rb index e6cef97..8e88448 100644 --- a/lib/liquid/tags/render.rb +++ b/lib/liquid/tags/render.rb @@ -3,7 +3,7 @@ module Liquid class Render < Tag SYNTAX = /(#{QuotedString})#{QuotedFragment}*/o - DISABLED_TAGS = %w(include) + DISABLED_TAGS = %w(include).freeze attr_reader :template_name_expr, :attributes diff --git a/test/integration/registers/disabled_tags_test.rb b/test/integration/registers/disabled_tags_test.rb index 1f26f6c..b784888 100644 --- a/test/integration/registers/disabled_tags_test.rb +++ b/test/integration/registers/disabled_tags_test.rb @@ -23,13 +23,13 @@ class DisabledTagsTest < Minitest::Test def test_disables_raw 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 def test_disables_echo_and_raw 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 diff --git a/test/integration/tags/render_tag_test.rb b/test/integration/tags/render_tag_test.rb index f7a3b8e..87373a2 100644 --- a/test/integration/tags/render_tag_test.rb +++ b/test/integration/tags/render_tag_test.rb @@ -153,7 +153,7 @@ class RenderTagTest < Minitest::Test '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 def test_includes_will_not_render_inside_nested_sibling_tags @@ -163,6 +163,6 @@ class RenderTagTest < Minitest::Test '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