{% spaceless %}{% load i18n l10n sekizai_tags static cms_tags %}

<template class="cms-plugin cms-plugin-start cms-plugin-{% if generic %}{{ generic.app_label }}-{{ generic.model_name }}-{% if attribute_name %}{{ attribute_name|slugify }}-{% endif %}{% endif %}{{ instance.pk|unlocalize }}{% if render_model_icon %} cms-render-model-icon{% elif render_model %} cms-render-model{% elif render_model_block %} cms-render-model cms-render-model-block{% elif render_model_add %} cms-render-model-add{% endif %}"></template>
{% endspaceless %}{% if content %}{{ content }}{% elif render_model_icon %}<img src="{% static 'cms/img/toolbar/render_model_placeholder.png' %}">{% elif render_model_add %}<img src="{% static 'cms/img/toolbar/render_model_placeholder.png' %}">{% else %}{{ rendered_content }}{% endif %}{% spaceless %}
<template class="cms-plugin cms-plugin-end cms-plugin-{% if generic %}{{ generic.app_label }}-{{ generic.model_name }}-{% if attribute_name %}{{ attribute_name|slugify }}-{% endif %}{% endif %}{{ instance.pk|unlocalize }}{% if render_model_icon %} cms-render-model-icon{% elif render_model %} cms-render-model{% elif render_model_block %} cms-render-model cms-render-model-block{% elif render_model_add %} cms-render-model-add{% endif %}"></template>

{% addtoblock "js" %}
<script id="cms-plugin-{% if generic %}{{ generic.app_label }}-{{ generic.model_name }}-{% if attribute_name %}{{ attribute_name|slugify }}-{% endif %}{% endif %}{{ instance.pk|unlocalize }}" type="application/json"{% if generic %} data-cms-general{% endif %}>{% spaceless %}{
    "type": {% if generic %}"generic"{% else %}"plugin"{% endif %},
    "placeholder_id": "{{ instance.placeholder_id|unlocalize }}",
    "plugin_name": "{{ instance.get_plugin_name|default:"" }}",
    "plugin_type": "{{ instance.plugin_type }}",
    "plugin_id": "{{ instance.pk|unlocalize }}",
    "plugin_language": "{{ instance.language|default:"" }}",
    {% if instance.node_id %}
        "plugin_parent": "{{ instance.parent_page.pk|unlocalize }}",
    {% else %}
        "plugin_parent": "{{ instance.parent_id|unlocalize }}",
    {% endif %}
    "plugin_order": "{{ instance.plugin_order }}",{% language request.toolbar.toolbar_language %}
    "plugin_restriction": [{% for cls in allowed_child_classes %}"{{ cls }}"{% if not forloop.last %},{% endif %}{% endfor %}],
    "plugin_parent_restriction": [{% for cls in allowed_parent_classes %}"{{ cls }}"{% if not forloop.last %},{% endif %}{% endfor %}],
    "onClose": {% if refresh_page %}"REFRESH_PAGE"{% else %}{% if redirect_on_close %}"{{ redirect_on_close }}"{% else %}false{% endif %}{% endif %},
    "addPluginHelpTitle": "{% trans 'Add plugin to' %} {{ instance.get_plugin_name|escapejs }}",
    "urls": {
        "add_plugin": "{% if add_url %}{{ add_url }}{% else %}{% cms_admin_url "cms_placeholder_add_plugin" %}{% endif %}",
        "edit_plugin": "{% if edit_url %}{{ edit_url }}{% elif instance %}{% cms_admin_url "cms_placeholder_edit_plugin" instance.pk %}{% endif %}",
        "move_plugin": "{% if move_url %}{{ move_url }}{% else %}{% cms_admin_url "cms_placeholder_move_plugin" %}{% endif %}",
        "delete_plugin": "{% if delete_url %}{{ delete_url }}{% elif instance %}{% cms_admin_url "cms_placeholder_delete_plugin" instance.pk %}{% endif %}",
        "copy_plugin": "{% if copy_url %}{{ copy_url }}{% else %}{% cms_admin_url "cms_placeholder_copy_plugins" %}{% endif %}"
    } {% endlanguage %}
}{% endspaceless %}</script>{% endaddtoblock %}
{% endspaceless %}
