<div class="container">
  <a id="debug-toggle" href="#debug" style="opacity: 0.6">Debug {{ request.environ['CKAN_DEBUG_INFO']|length }}</a>
  <div id="debug" class="well" style="display:none;color:#333;margin-top:10px;white-space:pre;">
<b>Debug info:</b>

<b>Controller</b>: {{ c.controller }}
<b>Action</b>: {{ c.action }}
<b>Templates Rendered</b>: {{ request.environ['CKAN_DEBUG_INFO']|length }}
{% for info in request.environ['CKAN_DEBUG_INFO'] %}
<b>Template name</b>: {{ info.template_name }}
<b>Template path</b>: {{ info.template_path }}
<b>Template type</b>: {{ info.template_type }}
<b>Renderer</b>: {{ info.renderer }}
<hr/>
{%- endfor %}
</div>
  <script>
    (function () {
      function nextElementSibling(element) {
        do {
          element = element.nextSibling;
        } while (element && element.nodeType !== 1 /* Node.ELEMENT_NODE */);

        return element || null;
      }

      function toggleElement(element) {
        if (element && element.style) {
          element.style.display = element.style.display === 'block' ? 'none' : 'block';
        }
      }

      function getElementsByClassName(className) {
        if (document.getElementsByClassName) {
          return document.getElementsByClassName(className);
        } else {
          var elements = document.getElementsByTagName('*');
          var index = 0;
          var length = elements.length;
          var captures = [];
          var regexp = new RegExp('\\b' + className + '\\b', 'i');

          for (; index < length; index += 1) {
            if (regexp.test(elements[index].className)) {
              captures.push(elements[index]);
            }
          }
          return captures;
        }
      }

      (function toggleDebug() {
        var debug  = document.getElementById('debug'),
        toggle = document.getElementById('debug-toggle');

        toggle.onclick = function () {
          toggleElement(debug);
          return false;
        };
      })();
    })();
  </script>
</div>
