{%- 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 #}
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        {% block header_text %}
            <h3>{{ _gettext('Rename %(name)s', name=name) }}</h3>
        {% endblock %}
      </div>
      <div class="modal-body">
        {{ lib.render_form(form, dir_url, action=request.url, is_modal=True) }}
      </div>
    {%- else -%}
      <h3>{{ self.header_text() }}</h3>
      {{ lib.render_form(form, dir_url) }}
    {%- endif -%}
{% endblock %}

{% block tail %}
    {%- if modal -%}
    <script>
    // fixes "remote modal shows same content every time", avoiding the flicker
    $('body').on('hidden.bs.modal', '.modal', function() {
        $(this).removeData('bs.modal').find(".modal-content").empty();
    });
    </script>
    {%- endif -%}
{% endblock %}
