wcm-io / io.wcm.wcm.ui.clientlibs

Extensions for AEM HTML client libraries.
Apache License 2.0
2 stars 0 forks source link

Setting additional (data-)attributes on the rendered script/link tag #1

Closed henrykuijpers closed 11 months ago

henrykuijpers commented 1 year ago

It would be nice to be able to set additional attributes on the rendered script/link tags.

In our case, we want to specify "rel" and "title", and also "data-contrast" to indicate that our stylesheet is for the contrast option.

It would be good to change the HTL helper, for example by allowing the specification of a map (or similar), so that any attributes can be specified and we don't have to deal with a hardcoded list of supported attributes. This way, we don't have to do code changes when something new needs to be supported.

stefanseifert commented 1 year ago

i've a proposal in #2 - can you give it a try?

<sly data-sly-use.clientlib="/apps/wcm-io/wcm/ui/clientlibs/sightly/templates/clientlib.html"
    data-sly-call="${clientlib.css @ categories=['my-clientlib-category'],
    customAttributes=['attr1=value 1','data-attr2=5','attr3']}"/>
<sly data-sly-use.clientlib="/apps/wcm-io/wcm/ui/clientlibs/sightly/templates/clientlib.html"
    data-sly-call="${clientlib.js @ categories=['my-clientlib-category'],
    customAttributes=['attr1=value 1','data-attr2=5','attr3']}"/>
stefanseifert commented 11 months ago

@henrykuijpers is this still relevant? can you have a look at the PR?

henrykuijpers commented 11 months ago

Oops! totally forgot about this one. Yes, this is still relevant. :) I'll review the PR. :)