Module: BetterErrors::FrameWithLiquidContext

Extended by:
ActiveSupport::Concern
Included in:
StackFrame
Defined in:
lib/locomotive/steam/monkey_patches/better_errors.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#local_variables_with_liquid_contextObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/locomotive/steam/monkey_patches/better_errors.rb', line 36

def local_variables_with_liquid_context
  if self.liquid_context
    scope = self.liquid_context.scopes.last.clone

    scope.delete_if { |k, _| %w(models contents params session).include?(k) }.tap do |_scope|
      _scope['site'] = _scope['site'].send(:_source).to_hash
      _scope['page'] = _scope['page'].to_hash.delete_if { |k, _| %w(template).include?(k) }
    end
  else
    self.local_variables_without_liquid_context
  end
rescue Exception => e
  puts "[BetterError] Fatal error: #{e.message}".red
  puts e.backtrace.join("\n")
  {}
end