title: How to pass arguments to django's custom template (block) tags
body: <p>I was trying to make reusable interface components with django. I was able to pull something off with custom template tags:</p>
  
  <pre><code>{% panel %}
      Some panel content
  {% endpanel %}
  </code></pre>
  
  <p>It works fine but I wasn't able to pass the panel title as an argument. What I really wanted was something like:</p>
  
  <pre><code>{% panel 'Panel Title' %}
      Some panel content
  {% endpanel %}
  </code></pre>
  
  <p>I couldn't find an answer for this in the docs. Is there a way to achieve it? If not, is there another strategy that I could use?</p>
  
  <blockquote>
    <p><strong>edit</strong>: Keep in mind that the panel content is suposed to accept more markup inside, like other tags and blocks. That's why a simple template tag was not enough for me.</p>
  </blockquote>
  
  <hr>
  
  <h2>Details</h2>
  
  <p>panel.html</p>
  
  <pre><code>&lt;div class="panel panel-default"&gt;
      &lt;div class="panel-heading"&gt;{{ title|default:"Panel Title" }}&lt;/div&gt;
      &lt;div class="panel-body"&gt;
          {{ body }}
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>templatetags/theme.py</p>
  
  <pre><code>from django import template
  
  
  register = template.Library()
  
  
  @register.tag
  def panel(parser, token):
      nodelist = parser.parse(('endpanel',))
      parser.delete_first_token()
      return PanelNode(nodelist)
  
  
  class PanelNode(template.Node):
      def __init__(self, nodelist):
          self.nodelist = nodelist
  
      def render(self, context):
          output = self.nodelist.render(context)
          t = template.loader.get_template('theme/blocks/panel.html')
          c = template.Context({'body': output})
          return t.render(c)
  </code></pre>