Class: Rack::Bug::MustachePanel::View

Inherits:
Mustache
  • Object
show all
Defined in:
lib/rack/bug/panels/mustache_panel.rb

Overview

The view is responsible for rendering our panel. While Rack::Bug takes care of the nav, the content rendered by View is used for the panel itself.

Instance Method Summary collapse

Instance Method Details

#timesObject

We track the render times of all the Mustache views on this page load.



18
19
20
21
22
# File 'lib/rack/bug/panels/mustache_panel.rb', line 18

def times
  MustachePanel.times.each_with_object({}) do |obj, key, value|
    obj[key] = value
  end
end

#variablesObject

Any variables used in this page load are collected and displayed.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rack/bug/panels/mustache_panel.rb', line 25

def variables
  vars = MustachePanel.variables.sort_by { |key, _| key.to_s }
  vars.map do |key, value|
    # Arrays can get too huge. Just show the first 10 (LIMIT) to give you
    # some idea.
    size = value.size

    if value.is_a?(Array) && size > LIMIT
      value = value.first(LIMIT)
      value << "...and #{size - LIMIT} more"
    end

    { :key => key, :value => value.inspect }
  end
end