Sha256: ef7c17dc9b38b82ae3a0b464d299737d17a954945b397a88ea81e7aa49a1d0b9

Contents?: true

Size: 991 Bytes

Versions: 7

Compression:

Stored size: 991 Bytes

Contents

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

    def initialize(options = {})
      @template_options = options ? options.dup : {}
      @locale = @template_options[:locale] ||= I18n.new
      @warnings = []
      self.depth = 0
      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

7 entries across 7 versions & 3 rubygems

Version Path
liquid-4.0.4 lib/liquid/parse_context.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/liquid-4.0.3/lib/liquid/parse_context.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/liquid-4.0.3/lib/liquid/parse_context.rb
liquid-4.0.3 lib/liquid/parse_context.rb
liquid-4.0.2 lib/liquid/parse_context.rb
liquid-4-0-2-4.0.2 lib/liquid/parse_context.rb
liquid-4.0.1 lib/liquid/parse_context.rb