{% macro download_button(storedObject, filename = null) %}
    {% if storedObject is null %}
        <!-- No document to download -->
    {% else %}
        <a class="btn btn-download"
           data-label-preparing="{{ ('Preparing'|trans ~ '...')|escape('html_attr') }}"
           data-label-ready="{{ 'Ready to show'|trans|escape('html_attr') }}"
           data-download-button
           data-key="{{ storedObject.keyInfos|json_encode|escape('html_attr') }}"
           data-iv="{{ storedObject.iv|json_encode|escape('html_attr') }}"
           data-temp-url-get-generator="{{ storedObject|generate_url|escape('html_attr') }}"
           data-mime-type="{{ storedObject.type|escape('html_attr') }}" {% if filename is not null %}data-filename="{{ filename|escape('html_attr') }}"{% endif %}>
            {{ 'Download'|trans }}</a>
    {% endif %}
{% endmacro %}

{% macro download_button_small(storedObject, filename = null) %}
    {% if storedObject is null %}
        <!-- No document to download -->
    {% else %}
        <a class="btn btn-sm btn-download"
           data-label-preparing="{{ ('Preparing'|trans ~ '...')|escape('html_attr') }}"
           data-label-ready="{{ 'Ready to show'|trans|escape('html_attr') }}"
           data-download-button
           data-key="{{ storedObject.keyInfos|json_encode|escape('html_attr') }}"
           data-iv="{{ storedObject.iv|json_encode|escape('html_attr') }}"
           data-temp-url-get-generator="{{ storedObject|generate_url|escape('html_attr') }}"
           data-mime-type="{{ storedObject.type|escape('html_attr') }}" {% if filename is not null %}data-filename="{{ filename|escape('html_attr') }}"{% endif %}>
            {{ 'Download'|trans }}</a>
    {% endif %}
{% endmacro %}

{% macro download_button_group(storedObject, canEdit = true, filename = null, options = {}) %}
    {% if storedObject is null %}
        <!-- No document to download -->
    {% else %}
        <div
            data-download-buttons
            data-uuid="{{ storedObject.uuid|escape('html_attr') }}"
            data-key="{{ storedObject.keyInfos|json_encode|escape('html_attr') }}"
            data-iv="{{ storedObject.iv|json_encode|escape('html_attr') }}"
            data-temp-url-generator="{{ storedObject|generate_url|escape('html_attr') }}"
            data-mime-type="{{ storedObject.type|escape('html_attr') }}"
            data-can-edit="{{ canEdit ? '1' : '0' }}"
            {% if options['small'] is defined %}data-button-small="{{ options['small'] ? '1' : '0' }}"{% endif %}
            {% if filename|default(storedObject.title)|default(null) is not null %}data-filename="{{ filename|default(storedObject.title)|escape('html_attr') }}"{% endif %}></div>
    {% endif %}
{% endmacro %}
