title: Django: Invalid block tag: 'endif'
body: <p>Here is the relevant template tag and html:</p>
  
  <pre><code>from django import template
  from django.conf import settings
  
  register = template.Library()
  
  
  @register.inclusion_tag('auth_backend/templatetags/extends_layout.html')
  def extends_layout():
      layout_template = getattr(settings, 'AUTHBACKEND_LAYOUT_TEMPLATE', '')
      return {'layout': layout_template}
  
  
  {% if layout %}
    {% extends layout %} &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; Problem here
  {% endif %}
  </code></pre>
  
  <p>When I use it in a view, I get the following error:</p>
  
  <pre><code>{# Sample view #}
  {% load auth_backend_tags %}
  {% load staticfiles %}
  
  {% extends_layout %}
  </code></pre>
  
  <p><code>Django: Invalid block tag: 'endif'</code></p>
  
  <p>If I delete <code>{% extends layout %}</code> then the error goes away, except my template tag is now blank.</p>
  
  <p>What am I doing wrong?</p>