Abstract parser switching into tag

This commit is contained in:
Tristan Hume
2013-07-29 13:00:35 -04:00
parent d5d41a8202
commit 8f4b398c7a
2 changed files with 16 additions and 16 deletions

View File

@@ -22,5 +22,20 @@ module Liquid
def blank?
@blank || true
end
def switch_parse(markup)
case Template.error_mode
when :strict then strict_parse(markup)
when :lax then lax_parse(markup)
when :warn
begin
return strict_parse(markup)
rescue SyntaxError => e
@warnings ||= []
@warnings << e
return lax_parse(markup)
end
end
end
end # Tag
end # Liquid

View File

@@ -46,28 +46,13 @@ module Liquid
block = if tag == 'else'
ElseCondition.new
else
parse_condition(markup)
switch_parse(markup)
end
@blocks.push(block)
@nodelist = block.attach(Array.new)
end
def parse_condition(markup)
case Template.error_mode
when :strict then strict_parse(markup)
when :lax then lax_parse(markup)
when :warn
begin
return strict_parse(markup)
rescue SyntaxError => e
@warnings ||= []
@warnings << e
return lax_parse(markup)
end
end
end
def lax_parse(markup)
expressions = markup.scan(ExpressionsAndOperators).reverse
raise(SyntaxError, SyntaxHelp) unless expressions.shift =~ Syntax