Skip to content

Commit

Permalink
Have subclasses of a tag inherit superclass's disabled tags (#1646)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanahsmith authored Oct 27, 2022
1 parent 7ccac29 commit 3e8994c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
10 changes: 8 additions & 2 deletions lib/liquid/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 0 additions & 8 deletions lib/liquid/tag/disabler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3e8994c

Please sign in to comment.