_email_link.html.twig 716 B

123456789101112131415161718192021
  1. {%- if value is empty -%}
  2.  
  3. {%- elseif field_description.options.as_string is defined and field_description.options.as_string -%}
  4. {{ value }}
  5. {%- else -%}
  6. {% set parameters = {} %}
  7. {% set subject = field_description.options.subject|default('') %}
  8. {% set body = field_description.options.body|default('') %}
  9. {% if subject is not empty %}
  10. {% set parameters = parameters|merge({'subject': subject}) %}
  11. {% endif %}
  12. {% if body is not empty %}
  13. {% set parameters = parameters|merge({'body': body}) %}
  14. {% endif %}
  15. <a href="mailto:{{ value }}{% if parameters|length > 0 %}?{{- parameters|url_encode -}}{% endif %}">
  16. {{- value -}}
  17. </a>
  18. {%- endif -%}