mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
* Add ForceEqualSignAlignment to .rubocop.yml * Revert ForceEqualSignAlignment cop * Update method alignment * Undo addition of whitespace to improve readability * Fix missing alignment
34 lines
783 B
Ruby
34 lines
783 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Liquid
|
|
module ParserSwitching
|
|
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
|
|
|
|
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
|
|
|
|
def markup_context(markup)
|
|
"in \"#{markup.strip}\""
|
|
end
|
|
end
|
|
end
|