{#

This file is part of the Sonata package.

(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.

#}

{%- apply spaceless %}
    {%- if value is empty -%}
        &nbsp;
    {%- elseif as_string|default(false) -%}
        {{ value }}
    {%- else -%}
        {% set parameters = {} %}

        {% if subject|default(null) is not empty %}
            {% set parameters = parameters|merge({'subject': subject}) %}
        {% endif %}
        {% if body|default(null) is not empty %}
            {% set parameters = parameters|merge({'body': body}) %}
        {% endif %}

        <a href="mailto:{{ value }}{% if parameters|length > 0 %}?{{- parameters|url_encode -}}{% endif %}">
            {{- value -}}
        </a>
    {%- endif -%}
{% endapply -%}
