class Liquid::ParseContext

Attributes

depth[RW]
environment[R]
error_mode[R]
line_number[RW]
locale[RW]
partial[R]
trim_whitespace[RW]
warnings[R]

Public Class Methods

new(options = Const::EMPTY_HASH) click to toggle source
# File lib/liquid/parse_context.rb, line 8
def initialize(options = Const::EMPTY_HASH)
  @environment = options.fetch(:environment, Environment.default)
  @template_options = options ? options.dup : {}

  @locale   = @template_options[:locale] ||= I18n.new
  @warnings = []

  self.depth   = 0
  self.partial = false
end

Public Instance Methods

[](option_key) click to toggle source
# File lib/liquid/parse_context.rb, line 19
def [](option_key)
  @options[option_key]
end
new_block_body() click to toggle source
# File lib/liquid/parse_context.rb, line 23
def new_block_body
  Liquid::BlockBody.new
end
new_tokenizer(markup, start_line_number: nil, for_liquid_tag: false) click to toggle source
# File lib/liquid/parse_context.rb, line 27
def new_tokenizer(markup, start_line_number: nil, for_liquid_tag: false)
  Tokenizer.new(markup, line_number: start_line_number, for_liquid_tag: for_liquid_tag)
end
parse_expression(markup) click to toggle source
# File lib/liquid/parse_context.rb, line 31
def parse_expression(markup)
  Expression.parse(markup)
end
partial=(value) click to toggle source
# File lib/liquid/parse_context.rb, line 35
def partial=(value)
  @partial = value
  @options = value ? partial_options : @template_options

  @error_mode = @options[:error_mode] || @environment.error_mode
end
partial_options() click to toggle source
# File lib/liquid/parse_context.rb, line 42
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