Add ability to pass tags to parse_context

Co-authored-by: Dylan Thacker-Smith <[email protected]>
This commit is contained in:
Matt Rose
2022-09-29 11:35:46 -04:00
co-authored by Dylan Thacker-Smith
parent 456be2f75e
commit 3d2aa05d64
5 changed files with 37 additions and 8 deletions
+2 -6
View File
@@ -45,7 +45,7 @@ module Liquid
end
tag_name = Regexp.last_match(1)
markup = Regexp.last_match(2)
unless (tag = registered_tags[tag_name])
unless (tag = parse_context.tags[tag_name])
# end parsing if we reach an unknown tag and let the caller decide
# determine how to proceed
return yield tag_name, markup
@@ -132,7 +132,7 @@ module Liquid
next
end
unless (tag = registered_tags[tag_name])
unless (tag = parse_context.tags[tag_name])
# end parsing if we reach an unknown tag and let the caller decide
# determine how to proceed
return yield tag_name, markup
@@ -247,9 +247,5 @@ module Liquid
def raise_missing_variable_terminator(token, parse_context)
BlockBody.raise_missing_variable_terminator(token, parse_context)
end
def registered_tags
Template.tags
end
end
end
+2 -1
View File
@@ -2,7 +2,7 @@
module Liquid
class ParseContext
attr_accessor :locale, :line_number, :trim_whitespace, :depth
attr_accessor :locale, :line_number, :trim_whitespace, :depth, :tags
attr_reader :partial, :warnings, :error_mode
def initialize(options = {})
@@ -10,6 +10,7 @@ module Liquid
@locale = @template_options[:locale] ||= I18n.new
@warnings = []
@tags = @template_options[:tags] || Liquid::Template.tags
self.depth = 0
self.partial = false