Create a BlockBody class to decouple block body parsing from tags.

This commit is contained in:
Dylan Thacker-Smith
2014-11-03 17:07:42 -05:00
committed by Justin Li
parent 263e90e772
commit 73fcd42403
18 changed files with 253 additions and 157 deletions
+12 -11
View File
@@ -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