title: Display all jinja object attributes
body: <p>Is there a way to display the name/content/functions of all attributes of a given object in a jinja template. This would make it easier to debug a template that is not acting as expected. </p>
  
  <p>I am building a website using the <code>hyde</code> framework and this would come in quite handy since I am still learning the intricacies of both jinja and hyde.</p>
  
  <p>Originally, I had thought it would work to use the <code>attr</code> filter, but this seems to require a name value. I would like to to not have to specify the name in order to get all available attributes for the object.</p>
  
  <p>Some google searching showed django syntax looks like the following, but I am not familiar with django so this may only apply to database items. Long story short, I would like a method that works kind of like this for any object named <code>obj</code></p>
  
  <pre><code>{% for field, value in obj.get_fields %}
      {{ field }} : {{ value }} &lt;/br&gt;
  {% endfor %}
  </code></pre>
  
  <hr>
  
  <h3>final solution:</h3>
  
  <p>@jayven was right, I could create my own jinja2 filter. Unfortunately, using the stable version of hyde (0.8.4), this is not a trivial act of having a filter in the pythonpath and setting a simple yaml value in the <code>site.yaml</code> file (There is a pull-request for that). That being said, I was able to figure it out! So the following is my final solution which ends up being very helpful for debugging any unkown attributes.</p>
  
  <p>It's easy enough to create site-specific hyde extensions just create a local python package with the following  directory tree</p>
  
  <pre><code>hyde_ext
      __init__.py
      custom_filters.py
  </code></pre>
  
  <p>Now create the extension:</p>
  
  <pre><code>from hyde.plugin import Plugin
  from jinja2 import environmentfilter, Environment
  
  
  debug_attr_fmt = '''name:  %s
  type:  %r
  value: %r'''
  
  @environmentfilter
  def debug_attr(env, value, verbose=False):
      '''
      A jinja2 filter that creates a &lt;pre&gt; block
      that lists all the attributes of a given object
      inlcuding the value of those attributes and type.
  
      This filter takes an optional variable "verbose",
      which prints underscore attributes if set to True.
      Verbose printing is off by default.
      '''
  
      begin = "&lt;pre class='debug'&gt;\n"
      end = "\n&lt;/pre&gt;"
  
      result = ["{% filter escape %}"]
      for attr_name in dir(value):
          if not verbose and attr_name[0] == "_":
              continue
          a = getattr(value, attr_name)
          result.append(debug_attr_fmt % (attr_name, type(a), a))
      result.append("{% endfilter %} ")
      tmpl = Environment().from_string("\n\n".join(result))
  
      return begin + tmpl.render() + end
  
      #return "\n\n".join(result)
  
  # list of custom-filters for jinja2
  filters = {
          'debug_attr' : debug_attr
          }
  
  class CustomFilterPlugin(Plugin):
      '''
      The curstom-filter plugin allows any
      filters added to the "filters" dictionary
      to be added to hyde
      '''
      def __init__(self, site):
          super(CustomFilterPlugin, self).__init__(site)
  
      def template_loaded(self,template):
          super(CustomFilterPlugin, self).template_loaded(template)
          self.template.env.filters.update(filters)
  </code></pre>
  
  <p>To let hyde know about the extension add <code>hyde_ext.custom_filters.CustomFilterPlugin</code> to the "plugins" list of the <code>site.yaml</code> file.</p>
  
  <p>Lastly, test it out on a file, you can add this to some random page <code>{{resource|debug_attr}}</code> or the following to get even the underscore-attributes <code>{{resource|debug_attr(verbose=True)}}</code></p>
  
  <p>Of course, I should add, that it seems like this might become much easier in the future whenever hyde 1.0 is released. Especially since there is already a pull request waiting to implement a simpler solution. This was a great way to learn a little more about how to use jinja and hyde though!</p>