Code improvements

This commit is contained in:
Mike Angell
2019-09-25 23:33:46 +10:00
parent 9b2d0dc145
commit 644de4c4f5
5 changed files with 15 additions and 7 deletions

View File

@@ -154,8 +154,8 @@ module Liquid
private
def render_node(context, output, node)
return if node.is_a?(Tag) && node.disabled?(context, output)
disable_tags(context, node.is_a?(Tag) ? node.disabled_tags : nil) do
return if node.disabled?(context, output)
disable_tags(context, node.disabled_tags) do
node.render_to_output_buffer(context, output)
end
rescue UndefinedVariable, UndefinedDropMethod, UndefinedFilter => e

View File

@@ -13,8 +13,8 @@ module Liquid
tag
end
def disable_nested_tags(*tags)
@disabled_tags = tags
def disable_tags(*tags)
disabled_tags.push(*tags)
end
private :new

View File

@@ -4,7 +4,7 @@ module Liquid
class Render < Tag
SYNTAX = /(#{QuotedString})#{QuotedFragment}*/o
disable_nested_tags "include"
disable_tags "include"
attr_reader :template_name_expr, :attributes

View File

@@ -104,6 +104,14 @@ module Liquid
output
end
def disabled?(_context, _output)
false
end
def disabled_tags
[]
end
private
def parse_filter_expressions(filter_name, unparsed_args)

View File

@@ -6,11 +6,11 @@ class DisabledTagsTest < Minitest::Test
include Liquid
class DisableRaw < Block
disable_nested_tags "raw"
disable_tags "raw"
end
class DisableRawEcho < Block
disable_nested_tags "raw", "echo"
disable_tags "raw", "echo"
end
def test_disables_raw