From 3e8994c258e709b611fd4b2259f4e65cc68a754c Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Thu, 27 Oct 2022 11:13:50 -0400 Subject: [PATCH] Have subclasses of a tag inherit superclass's disabled tags (#1646) --- lib/liquid/tag.rb | 10 ++++++++-- lib/liquid/tag/disabler.rb | 8 -------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/liquid/tag.rb b/lib/liquid/tag.rb index 085c0efc5..2f7bc3016 100644 --- a/lib/liquid/tag.rb +++ b/lib/liquid/tag.rb @@ -14,12 +14,18 @@ def parse(tag_name, markup, tokenizer, parse_context) end def disable_tags(*tag_names) - @disabled_tags ||= [] - @disabled_tags.concat(tag_names) + tag_names += disabled_tags + define_singleton_method(:disabled_tags) { tag_names } prepend(Disabler) end private :new + + protected + + def disabled_tags + [] + end end def initialize(tag_name, markup, parse_context) diff --git a/lib/liquid/tag/disabler.rb b/lib/liquid/tag/disabler.rb index 210a177d7..852205abc 100644 --- a/lib/liquid/tag/disabler.rb +++ b/lib/liquid/tag/disabler.rb @@ -3,14 +3,6 @@ module Liquid class Tag module Disabler - module ClassMethods - attr_reader :disabled_tags - end - - def self.prepended(base) - base.extend(ClassMethods) - end - def render_to_output_buffer(context, output) context.with_disabled_tags(self.class.disabled_tags) do super