mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-18 02:10:41 -07:00
Create a BlockBody class to decouple block body parsing from tags.
This commit is contained in:
committed by
Justin Li
parent
263e90e772
commit
73fcd42403
+12
-11
@@ -1,17 +1,18 @@
|
||||
module Liquid
|
||||
class Document < Block
|
||||
def self.parse(tokens, options={})
|
||||
# we don't need markup to open this block
|
||||
super(nil, nil, tokens, options)
|
||||
class Document < BlockBody
|
||||
def parse(tokens)
|
||||
super do |end_tag_name, end_tag_params|
|
||||
unknown_tag(end_tag_name) if end_tag_name
|
||||
end
|
||||
end
|
||||
|
||||
# There isn't a real delimiter
|
||||
def block_delimiter
|
||||
[]
|
||||
end
|
||||
|
||||
# Document blocks don't need to be terminated since they are not actually opened
|
||||
def assert_missing_delimitation!
|
||||
def unknown_tag(tag)
|
||||
case tag
|
||||
when 'else'.freeze, 'end'.freeze
|
||||
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))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user