{% extends use_theme|yesno:"theme.html,core_main_app/_render/user/default.html" %}

{% load staticfiles %}
{% load include_static %}

{% comment %}
    Template including the necessary template and static file for a given view. The file utils/rendering.py is rendering
    it using Django.
{% endcomment %}

{% block app_data %}
    {% include template with data=data %}
{% endblock %}

{% block app_modals %}
    {% for modal_file in modals %}
        {% include modal_file %}
    {% endfor %}
{% endblock %}

{% block app_css %}
    {% for css_file in assets.css %}
        <link rel="stylesheet" href="{% static css_file %}" />
    {% endfor %}
{% endblock %}

{% block app_js %}
    {% comment %}
        The js key from the asset dict should be formated like this:
            "js": [
                {
                    "path": "path/to/file_1.js",
                    "is_raw": True,
                    "is_external": False
                },
                ...
            ]

        The order of the list is the order of inclusion of the JavaScript files
    {% endcomment %}
    {% for js_file in assets.js %}
        {% if js_file.is_raw %}
            <script type="text/javascript">{% include_static js_file.path %}</script>
        {% elif js_file.is_external %}
            <script src="{{ js_file.path }}"></script>
        {% else %}
            <script src="{% static js_file.path %}"></script>
        {% endif %}
    {% endfor %}
{% endblock %}