{% if collection.legend %}<legend>{{ collection.legend }}</legend>{% endif %}
{% if collection.has_many %}
<div class="dj-collection-errors"{% if collection.prefix %} prefix="{{ collection.prefix }}"{% endif %}><ul class="dj-errorlist"></ul></div>
<div class="collection-siblings">
{% endif %}
{% for holder in collection %}
	{% if holder.is_single %}
	<django-form-collection{% if css_classes %} class="{{ css_classes }}"{% endif %}>
	{% elif holder.is_first %}
		{% if holder.is_template %}
	<template{% if collection.is_sortable %} sortable="true"{% endif %} prefix="{{ collection.prefix|default_if_none:0 }}" class="empty-collection">
		{% endif %}
	<django-form-collection sibling-position="{{ holder.position }}" min-siblings="{{ collection.min_siblings }}"{% if collection.max_siblings %} max-siblings="{{ collection.max_siblings }}"{% endif %}{% if css_classes %} class="{{ css_classes }}"{% endif %}>
		{% if collection.is_sortable %}
	<div class="collection-drag-handle"></div>
		{% endif %}
	{% endif %}
	{{ holder }}
	{% if holder.is_single %}
	</django-form-collection>
	{% elif holder.is_last %}
		{% include remove_collection_button %}
	</django-form-collection>
		{% if holder.is_template %}
	</template>
			{% include add_collection_button %}
		{% endif %}
	{% endif %}
{% endfor %}
{% if collection.has_many %}
</div>
{% endif %}