Sha256: c3c7d0b2c3465756aabe0a728741da8fc78b7c55fa9bd920a887d704ce4a8b8a

Contents?: true

Size: 944 Bytes

Versions: 1

Compression:

Stored size: 944 Bytes

Contents

module Liquid
  class ParseContext
    attr_accessor :partial, :locale, :line_number
    attr_reader :warnings, :error_mode

    def initialize(options = {})
      @template_options = options ? options.dup : {}
      @locale = @template_options[:locale] ||= I18n.new
      @warnings = []
      self.partial = false
    end

    def [](option_key)
      @options[option_key]
    end

    def partial=(value)
      @partial = value
      @options = value ? partial_options : @template_options
      @error_mode = @options[:error_mode] || Template.error_mode
      value
    end

    def partial_options
      @partial_options ||= begin
        dont_pass = @template_options[:include_options_blacklist]
        if dont_pass == true
          { locale: locale }
        elsif dont_pass.is_a?(Array)
          @template_options.reject { |k, v| dont_pass.include?(k) }
        else
          @template_options
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
liquid-4.0.0.rc1 lib/liquid/parse_context.rb