diff --git a/lib/liquid/parser.rb b/lib/liquid/parser.rb index f975d982..98870e23 100644 --- a/lib/liquid/parser.rb +++ b/lib/liquid/parser.rb @@ -1,6 +1,4 @@ module Liquid - # This class is used by tags to parse themselves - # it provides helpers and encapsulates state class Parser def initialize(input) l = Lexer.new(input) @@ -54,7 +52,6 @@ module Liquid variable_signature elsif [:string, :number].include? token[0] consume - token[1] elsif token.first == :open_round consume first = expression diff --git a/lib/liquid/tag.rb b/lib/liquid/tag.rb index 2fe17c93..9a354d46 100644 --- a/lib/liquid/tag.rb +++ b/lib/liquid/tag.rb @@ -3,14 +3,8 @@ module Liquid attr_accessor :nodelist, :options def self.new_with_options(tag_name, markup, tokens, options) - # Forgive me Matz for I have sinned. - # I have forsaken the holy idioms of Ruby and used Class#allocate. - # I fulfilled my mandate by maintaining API compatibility and performance, - # even though it may displease your Lordship. - # - # In all seriousness though, I can prove to a reasonable degree of certainty - # that setting options before calling initialize is required to maintain API compatibility. - # I tried doing it without it and not only did I break compatibility, it was much slower. + # Forgive me Matz for I have sinned. I know this code is weird + # but it was necessary to maintain API compatibility. new_tag = self.allocate new_tag.options = options new_tag.send(:initialize, tag_name, markup, tokens) @@ -39,7 +33,7 @@ module Liquid @blank || true end - def switch_parse(markup) + def parse_with_selected_parser(markup) case @options[:error_mode] || Template.error_mode when :strict then strict_parse(markup) when :lax then lax_parse(markup) diff --git a/lib/liquid/tags/for.rb b/lib/liquid/tags/for.rb index f3cf03e2..69fc9d33 100644 --- a/lib/liquid/tags/for.rb +++ b/lib/liquid/tags/for.rb @@ -47,7 +47,7 @@ module Liquid Syntax = /\A(#{VariableSegment}+)\s+in\s+(#{QuotedFragment}+)\s*(reversed)?/o def initialize(tag_name, markup, tokens) - switch_parse(markup) + parse_with_selected_parser(markup) @nodelist = @for_block = [] super end diff --git a/lib/liquid/tags/if.rb b/lib/liquid/tags/if.rb index 2ff061bc..d573afdd 100644 --- a/lib/liquid/tags/if.rb +++ b/lib/liquid/tags/if.rb @@ -46,7 +46,7 @@ module Liquid block = if tag == 'else' ElseCondition.new else - switch_parse(markup) + parse_with_selected_parser(markup) end @blocks.push(block) @@ -79,7 +79,7 @@ module Liquid while op = (p.id?('and') || p.id?('or')) new_cond = parse_comparison(p) - new_cond.send(op.to_sym, condition) + new_cond.send(op, condition) condition = new_cond end p.consume(:end_of_string)