mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-18 10:20:43 -07:00
Avoid storing options instance variable in BlockBody.
There is no need to pass parse options to the BlockBody initializer, since it does all the parsing in the parse method, unlike tags which parse the tag markup in the initializer.
This commit is contained in:
committed by
Justin Li
parent
73fcd42403
commit
15e1d46125
+11
-5
@@ -1,17 +1,23 @@
|
||||
module Liquid
|
||||
class Document < BlockBody
|
||||
def parse(tokens)
|
||||
def self.parse(tokens, options)
|
||||
doc = new
|
||||
doc.parse(tokens, options)
|
||||
doc
|
||||
end
|
||||
|
||||
def parse(tokens, options)
|
||||
super do |end_tag_name, end_tag_params|
|
||||
unknown_tag(end_tag_name) if end_tag_name
|
||||
unknown_tag(end_tag_name, options) if end_tag_name
|
||||
end
|
||||
end
|
||||
|
||||
def unknown_tag(tag)
|
||||
def unknown_tag(tag, options)
|
||||
case tag
|
||||
when 'else'.freeze, 'end'.freeze
|
||||
raise SyntaxError.new(@options[:locale].t("errors.syntax.unexpected_outer_tag".freeze, :tag => tag))
|
||||
raise SyntaxError.new(options[:locale].t("errors.syntax.unexpected_outer_tag".freeze, :tag => tag))
|
||||
else
|
||||
raise SyntaxError.new(@options[:locale].t("errors.syntax.unknown_tag".freeze, :tag => tag))
|
||||
raise SyntaxError.new(options[:locale].t("errors.syntax.unknown_tag".freeze, :tag => tag))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user