Module: Liquid::ParserSwitching

Included in:
Tag, Variable
Defined in:
lib/liquid/parser_switching.rb

Instance Method Summary collapse

Instance Method Details

#parse_with_selected_parser(markup) ⇒ Object


17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/liquid/parser_switching.rb', line 17

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
      strict_parse_with_error_context(markup)
    rescue SyntaxError => e
      parse_context.warnings << e
      lax_parse(markup)
    end
  end
end

#strict_parse_with_error_mode_fallback(markup) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
# File 'lib/liquid/parser_switching.rb', line 5

def strict_parse_with_error_mode_fallback(markup)
  strict_parse_with_error_context(markup)
rescue SyntaxError => e
  case parse_context.error_mode
  when :strict
    raise
  when :warn
    parse_context.warnings << e
  end
  lax_parse(markup)
end