mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Move disabled check to block_body
This commit is contained in:
@@ -154,6 +154,7 @@ module Liquid
|
||||
private
|
||||
|
||||
def render_node(context, output, node)
|
||||
node.disabled?(context, output) && return if node.is_a?(Tag)
|
||||
node.render_to_output_buffer(context, output)
|
||||
rescue UndefinedVariable, UndefinedDropMethod, UndefinedFilter => e
|
||||
context.handle_error(e, node.line_number)
|
||||
|
||||
@@ -45,7 +45,6 @@ module Liquid
|
||||
end
|
||||
|
||||
def render_to_output_buffer(context, output)
|
||||
disabled?(context, output) && return
|
||||
template_name = context.evaluate(@template_name_expr)
|
||||
raise ArgumentError, options[:locale].t("errors.argument.include") unless template_name
|
||||
|
||||
|
||||
35
test/integration/registers/disabled_tags_test.rb
Normal file
35
test/integration/registers/disabled_tags_test.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class DisabledTagsTest < Minitest::Test
|
||||
include Liquid
|
||||
|
||||
class DisableRaw < Block
|
||||
def render(context)
|
||||
disable_tags(context, ["raw"]) do
|
||||
@body.render(context)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class DisableRawEcho < Block
|
||||
def render(context)
|
||||
disable_tags(context, ["raw", "echo"]) do
|
||||
@body.render(context)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
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 %}'
|
||||
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 %}'
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class DisabledTagsTest < Minitest::Test
|
||||
class DisabledTagsUnitTest < Minitest::Test
|
||||
include Liquid
|
||||
|
||||
def test_disables_tag_specified
|
||||
Reference in New Issue
Block a user