Class: Liquid::ParseContext

Inherits:
Object
  • Object
show all
Defined in:
lib/liquid/parse_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ParseContext

Returns a new instance of ParseContext.



6
7
8
9
10
11
# File 'lib/liquid/parse_context.rb', line 6

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

Instance Attribute Details

#error_modeObject (readonly)

Returns the value of attribute error_mode.



4
5
6
# File 'lib/liquid/parse_context.rb', line 4

def error_mode
  @error_mode
end

#line_numberObject

Returns the value of attribute line_number.



3
4
5
# File 'lib/liquid/parse_context.rb', line 3

def line_number
  @line_number
end

#localeObject

Returns the value of attribute locale.



3
4
5
# File 'lib/liquid/parse_context.rb', line 3

def locale
  @locale
end

#partialObject

Returns the value of attribute partial.



4
5
6
# File 'lib/liquid/parse_context.rb', line 4

def partial
  @partial
end

#trim_whitespaceObject

Returns the value of attribute trim_whitespace.



3
4
5
# File 'lib/liquid/parse_context.rb', line 3

def trim_whitespace
  @trim_whitespace
end

#warningsObject (readonly)

Returns the value of attribute warnings.



4
5
6
# File 'lib/liquid/parse_context.rb', line 4

def warnings
  @warnings
end

Instance Method Details

#[](option_key) ⇒ Object



13
14
15
# File 'lib/liquid/parse_context.rb', line 13

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

#partial_optionsObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/liquid/parse_context.rb', line 24

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