- 🇺🇸United States smustgrave
This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request → as a guide.
@imclean I do think this could use a test case. To least show that altering works as expected.
- 🇦🇺Australia imclean Tasmania
Still needs tests.
At the very least this should be updated as it's simply incorrect.
* - attributes: An associative array of attributes to be placed in the a tag. */ function template_preprocess_file_link(&$variables): void {}
file-link.html.twig:
<span{{ attributes }}>{{ link }}</span> {% if file_size %} <span>({{ file_size }})</span> {% endif %}
The attributes are applied to the wrapper element, not the a tag. See file.module for what's done with attributes.
- First commit to issue fork.
- 🇮🇳India mohit_aghera Rajkot
- Added a test to validate that attribute passed is exist on the render.
- Variable hint in the twig template. - 🇨🇭Switzerland berdir Switzerland
I'm a bit unclear what the specific issue is now.
I worked with @arla in 2016 when we did encounter this, but things have changed since then. We did deprecate and remove Drupal::l() and replace it with a Link::toRenderable(), so you should be able to alter this in additional preprocess functions as it is an array and not just a string now.
So it is possible to *alter* file_link template and its link structure and attributes. The thing I see is that it might be difficult to get enough context, for some cases you might want to alter only specific fields or so, then you'd want to alter the render array before this bit is rendered.
Additionally to the title, the issue summary also needs to be updated with the proposed solution and use cases why it's useful.