[MGNLRES-300] Generic Resource Linking Created: 20/Apr/17  Updated: 14/Dec/23  Resolved: 14/Dec/23

Status: Closed
Project: Magnolia Resources Module
Component/s: None
Affects Version/s: None
Fix Version/s: 4.0.0, 3.0.10

Type: Improvement Priority: Neutral
Reporter: Matthias Müller Assignee: Quach Hao Thien
Resolution: Fixed Votes: 3
Labels: VN-Analysis, nucleus
Remaining Estimate: Not Specified
Time Spent: 2d 3.5h
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Release notes required:
Yes
Documentation update required:
Yes
Date of First Response:
Epic Link: Maintenance of Resources module
Story Points: 5
Team: Nucleus
Work Started:
Approved:
Yes

 Description   

The module magnolia-resources-templating provides with "restfn" the possibility to include JavaScript and CSS resources directly. As the provided templating functions "cachedJs" and "cachedCss" render the whole HTML Tag, some use cases are not covered by this very specific solution:

  • "<script>"-tags with additional attributes like "async"
  • other types of resources (e.g. a favicon)

A generic solution, returning only the resource-link(s) would be nice and future-proof:

<link rel="apple-touch-icon" href="${resfn.cached('/some-module/resources/touch-icon.png')}">
[#list resfn.cachedList('/some-module/*.js') as link]
<script src="${link}" async></script>
[/#list]


 Comments   
Comment by Kathrin Kaufleitner [ 31/Jan/20 ]

another great improvement would be to add the 'otherAttributes' Parameter to the resfn-js as resfn-css already has:

String js(String pattern, String otherAttributes)

Comment by Quach Hao Thien [ 03/Mar/22 ]

Discovery completed

Provide APIs to allow user adds optional attributes to <script> tag

  • js(String pattern, String otherAttributes)
  • js(List<String> patterns, String otherAttributes)
  • cachedJs(String pattern, String otherAttributes)
  • cachedJs(List<String> patterns, String otherAttributes)

ref: https://git.magnolia-cms.com/projects/MODULES/repos/resources/browse/magnolia-resources-templating/src/main/java/info/magnolia/modules/resources/templating/ResourcesTemplatingFunctions.java#120,134,148,162,288

Generated at Mon Feb 12 06:49:21 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.