mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Code improvements
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user