mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-20 11:20:41 -07:00
Code improvements
This commit is contained in:
@@ -154,8 +154,8 @@ module Liquid
|
|||||||
private
|
private
|
||||||
|
|
||||||
def render_node(context, output, node)
|
def render_node(context, output, node)
|
||||||
return if node.is_a?(Tag) && node.disabled?(context, output)
|
return if node.disabled?(context, output)
|
||||||
disable_tags(context, node.is_a?(Tag) ? node.disabled_tags : nil) do
|
disable_tags(context, node.disabled_tags) do
|
||||||
node.render_to_output_buffer(context, output)
|
node.render_to_output_buffer(context, output)
|
||||||
end
|
end
|
||||||
rescue UndefinedVariable, UndefinedDropMethod, UndefinedFilter => e
|
rescue UndefinedVariable, UndefinedDropMethod, UndefinedFilter => e
|
||||||
|
|||||||
+2
-2
@@ -13,8 +13,8 @@ module Liquid
|
|||||||
tag
|
tag
|
||||||
end
|
end
|
||||||
|
|
||||||
def disable_nested_tags(*tags)
|
def disable_tags(*tags)
|
||||||
@disabled_tags = tags
|
disabled_tags.push(*tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
private :new
|
private :new
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ module Liquid
|
|||||||
class Render < Tag
|
class Render < Tag
|
||||||
SYNTAX = /(#{QuotedString})#{QuotedFragment}*/o
|
SYNTAX = /(#{QuotedString})#{QuotedFragment}*/o
|
||||||
|
|
||||||
disable_nested_tags "include"
|
disable_tags "include"
|
||||||
|
|
||||||
attr_reader :template_name_expr, :attributes
|
attr_reader :template_name_expr, :attributes
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,14 @@ module Liquid
|
|||||||
output
|
output
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def disabled?(_context, _output)
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
def disabled_tags
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def parse_filter_expressions(filter_name, unparsed_args)
|
def parse_filter_expressions(filter_name, unparsed_args)
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ class DisabledTagsTest < Minitest::Test
|
|||||||
include Liquid
|
include Liquid
|
||||||
|
|
||||||
class DisableRaw < Block
|
class DisableRaw < Block
|
||||||
disable_nested_tags "raw"
|
disable_tags "raw"
|
||||||
end
|
end
|
||||||
|
|
||||||
class DisableRawEcho < Block
|
class DisableRawEcho < Block
|
||||||
disable_nested_tags "raw", "echo"
|
disable_tags "raw", "echo"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_disables_raw
|
def test_disables_raw
|
||||||
|
|||||||
Reference in New Issue
Block a user