Sha256: 793fb78752e6b23b49aa6ddd1f47fcd1bed3313faeeb5e90f05ef1786b05cae3

Contents?: true

Size: 795 Bytes

Versions: 11

Compression:

Stored size: 795 Bytes

Contents

module Liquid
  module ParserSwitching
    def parse_with_selected_parser(markup)
      case @options[:error_mode] || Template.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
          e.set_line_number_from_token(markup)
          @warnings ||= []
          @warnings << e
          return lax_parse(markup)
        end
      end
    end

    private
    def strict_parse_with_error_context(markup)
      strict_parse(markup)
    rescue SyntaxError => e
      e.markup_context = markup_context(markup)
      raise e
    end

    def markup_context(markup)
      "in \"#{markup.strip}\""
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
locomotivecms-liquid-4.0.0 lib/liquid/parser_switching.rb
liquid-3.0.6 lib/liquid/parser_switching.rb
liquid-3.0.5 lib/liquid/parser_switching.rb
liquid-3.0.4 lib/liquid/parser_switching.rb
liquid-3.0.3 lib/liquid/parser_switching.rb
liquid-3.0.2 lib/liquid/parser_switching.rb
locomotivecms-liquid-4.0.0.alpha2 lib/liquid/parser_switching.rb
locomotivecms-liquid-4.0.0.alpha1 lib/liquid/parser_switching.rb
locomotivecms-liquid-4.0.0.alpha lib/liquid/parser_switching.rb
liquid-3.0.1 lib/liquid/parser_switching.rb
liquid-3.0.0 lib/liquid/parser_switching.rb