dsfr4drupal-1.x-dev/templates/file/file-link.html.twig
templates/file/file-link.html.twig
{# Check that the "link" variable is in the expected format to prevent component error. #}
{# The Webform module replaces the "link" variable with a string if the file is uploaded to the private file storage. #}
{# @see webform_preprocess_file_link() #}
{% if link['#url'] is not defined %}
{% include '@file/templates/file-link.html.twig' %}
{% else %}
{% set direct_download = direct_download ?? false %}
{% if link['#attributes'].class %}
{% set attributes = attributes.addClass(link['#attributes'].class) %}
{% endif %}
{% if link['#attributes'].rel %}
{% set attributes = attributes.setAttribute('rel', link['#attributes'].rel) %}
{% endif %}
{% if link['#attributes'].target %}
{% set attributes = attributes.setAttribute('target', link['#attributes'].target) %}
{% endif %}
{% if link['#attributes'].title %}
{% set attributes = attributes.setAttribute('title', link['#attributes'].title) %}
{% endif %}
{% if direct_download %}
{% set attributes = attributes.setAttribute('download', true) %}
{% endif %}
{{ include('dsfr4drupal:link', {
'detail': file_size,
'label': link['#title'],
'url': link['#url'],
'is_download': true,
}) }}
{% endif %}
