module Liquid::ParserSwitching

Public Instance Methods

parse_with_selected_parser(markup) click to toggle source
# File lib/liquid/parser_switching.rb, line 3
def parse_with_selected_parser(markup)
  case parse_context.error_mode
  when :strict then strict_parse_with_error_context(markup)
  when :lax    then lax_parse(markup)
  when :warn
    begin
      return strict_parse_with_error_context(markup)
    rescue SyntaxError => e
      parse_context.warnings << e
      return lax_parse(markup)
    end
  end
end

Private Instance Methods

markup_context(markup) click to toggle source
# File lib/liquid/parser_switching.rb, line 27
def markup_context(markup)
  "in \"#{markup.strip}\""
end
strict_parse_with_error_context(markup) click to toggle source
# File lib/liquid/parser_switching.rb, line 19
def strict_parse_with_error_context(markup)
  strict_parse(markup)
rescue SyntaxError => e
  e.line_number = line_number
  e.markup_context = markup_context(markup)
  raise e
end