{% if diff is not none and previous_schema is not none and ('_before' in diff or '_after' in diff) %}
  {% set current_schema = schema %}
  {% if '_before' in diff %}
    <div class="data-diff-before">
    {% set data = diff['_before'] %}
    {% set schema = previous_schema %}
    {% include get_view_template(schema, container_style) %}
    </div>
  {% endif %}
  {% if '_after' in diff %}
    <div class="data-diff-after">
    {% set data = diff['_after'] %}
    {% set schema = current_schema %}
    {% include get_view_template(schema, container_style) %}
    </div>
  {% endif %}
  {% if '_before' in diff and '_after' in diff %}
    <div class="modal fade" id="diff_modal__{{ id_prefix }}" tabindex="-1" role="dialog" aria-labelledby="diff_modal_label__{{ id_prefix }}">
      <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
          <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <h4 class="modal-title" id="diff_modal_label__{{ id_prefix }}">{{ _('Changes between version #%(previous_version_id)s and version #%(version_id)s', previous_version_id=version_id-1, version_id=version_id) }}</h4>
        </div>
          <div class="modal-body">
            {{ to_diff_table( diff['_before'] | to_json_no_extra_escapes(4),  diff['_after'] | to_json_no_extra_escapes(4), _("Version #%(version_id)s", version_id=version_id - 1), _("Version #%(version_id)s", version_id=version_id)) | safe }}
          </div>
        </div>
      </div>
    </div>
    <div class="text-center">
      <button type="button" class="btn btn-default btn-xs diff-modal-button" data-toggle="modal" data-target="#diff_modal__{{ id_prefix }}">{{ _('Show Changes') }}</button>
    </div>
  {% endif %}
{% else %}
  {% include get_view_template(schema, container_style) %}
{% endif %}
