Adding attributes to script tag, for ClientLibrary includes | Community
Skip to main content
christopher_ca9
Level 2
October 16, 2015
Solved

Adding attributes to script tag, for ClientLibrary includes

  • October 16, 2015
  • 2 replies
  • 1680 views

 I would like to continue adding client library files to JSPs as follows:

  <cq:includeClientLib js="some-category" />

But I need to have control over the attributes in the resulting script include. In other words I might want to see

<script type="application/javascript" async defer data-attr="somedata" src="<path to clientlib.min.js></script>

I have not seen any document that explains how to achieve this. I was hoping for something similar to adding classes for cq:htmlTag. Clearly I could do this manually by adding the script tag myself, and manually adding the path to the clientlib, but then I lose the ability to reference by category, which is my major use case for using clientlibs.

Thanks,

Matt

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by JustinEd3

Hi Matt,

There's no way to change the HTML output by <cq:includeClientLib>. Rather you need to create your own tag which uses the HtmlLibraryManager to get the list of includes for a particular category (or set of categories) and use those to output the appropriate HTML.

What you describe with something like cq:htmlTag seems like a worthwhile enhancement. I'd suggest filing a DayCare issue with the details so that this can be added to the product roadmap.

Regards,

Justin

2 replies

JustinEd3Adobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

Hi Matt,

There's no way to change the HTML output by <cq:includeClientLib>. Rather you need to create your own tag which uses the HtmlLibraryManager to get the list of includes for a particular category (or set of categories) and use those to output the appropriate HTML.

What you describe with something like cq:htmlTag seems like a worthwhile enhancement. I'd suggest filing a DayCare issue with the details so that this can be added to the product roadmap.

Regards,

Justin

christopher_ca9
Level 2
October 16, 2015

Hi Justin,

Thanks for your help with this, much appreciated. I'll create the tag and use HtmlLibraryManager as you suggest.

I think adding a String[] property to accept various attribute value pairs would be a very helpful addition (or something similar). I'll create a DayCare issue.

Thanks again,

Matt