{%- if not modal -%}
  {% extends 'admin/master.html' %}
{%- endif -%}
{% import 'admin/lib.html' as lib with context %}

{% block body %}
  {%- if modal -%}
    {# content added to modal-content #}
    {{ lib.render_form(form, dir_url, action=request.url, is_modal=True) }}
  {%- else -%}
    <h3>{% block header_text -%}
      {{ _gettext('Rename %(name)s', name=name) }}
    {%- endblock %}</h3>
    {{ lib.render_form(form, dir_url) }}
  {%- endif -%}
{% endblock %}

{% block tail %}
  {%- if modal -%}
  <script>
  // fill the header of modal dynamically
  $('.modal-header h3').html('{{ self.header_text() }}');

  // fixes "remote modal shows same content every time"
  $('.modal').on('hidden', function() {
      $(this).removeData('modal');
  });
  </script>
  {%- endif -%}
{% endblock %}
