mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-20 11:20:41 -07:00
Have subclasses of a tag inherit superclass's disabled tags (#1646)
This commit is contained in:
+8
-2
@@ -14,12 +14,18 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def disable_tags(*tag_names)
|
def disable_tags(*tag_names)
|
||||||
@disabled_tags ||= []
|
tag_names += disabled_tags
|
||||||
@disabled_tags.concat(tag_names)
|
define_singleton_method(:disabled_tags) { tag_names }
|
||||||
prepend(Disabler)
|
prepend(Disabler)
|
||||||
end
|
end
|
||||||
|
|
||||||
private :new
|
private :new
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def disabled_tags
|
||||||
|
[]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(tag_name, markup, parse_context)
|
def initialize(tag_name, markup, parse_context)
|
||||||
|
|||||||
@@ -3,14 +3,6 @@
|
|||||||
module Liquid
|
module Liquid
|
||||||
class Tag
|
class Tag
|
||||||
module Disabler
|
module Disabler
|
||||||
module ClassMethods
|
|
||||||
attr_reader :disabled_tags
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.prepended(base)
|
|
||||||
base.extend(ClassMethods)
|
|
||||||
end
|
|
||||||
|
|
||||||
def render_to_output_buffer(context, output)
|
def render_to_output_buffer(context, output)
|
||||||
context.with_disabled_tags(self.class.disabled_tags) do
|
context.with_disabled_tags(self.class.disabled_tags) do
|
||||||
super
|
super
|
||||||
|
|||||||
Reference in New Issue
Block a user