@@ -82,19 +82,22 @@ public class JSInclude {
82
82
private String referrerpolicy ;
83
83
@ RequestAttribute (injectionStrategy = InjectionStrategy .OPTIONAL )
84
84
private String type ;
85
+ @ RequestAttribute (injectionStrategy = InjectionStrategy .OPTIONAL )
86
+ private Object customAttributes ;
85
87
86
88
private String include ;
87
89
88
90
@ PostConstruct
89
91
private void activate () {
90
92
// build include string
91
- String [] categoryArray = IncludeUtil .toCategoryArray (categories );
93
+ String [] categoryArray = IncludeUtil .toArray (categories );
92
94
if (categoryArray != null ) {
93
95
List <String > libraryPaths = IncludeUtil .getLibraryUrls (htmlLibraryManager , resourceResolver ,
94
96
categoryArray , LibraryType .JS );
95
97
if (!libraryPaths .isEmpty ()) {
96
98
Map <String , String > attrs = validateAndBuildAttributes ();
97
- this .include = buildIncludeString (libraryPaths , attrs );
99
+ Map <String , String > customAttrs = IncludeUtil .getCustomAttributes (customAttributes );
100
+ this .include = buildIncludeString (libraryPaths , attrs , customAttrs );
98
101
}
99
102
}
100
103
}
@@ -137,13 +140,16 @@ private void activate() {
137
140
* Build script tags for all client libraries with the defined custom script tag attributes set.
138
141
* @param libraryPaths Library paths
139
142
* @param attrs HTML attributes for script tag
143
+ * @param customAttrs Custom HTML attributes for script tag
140
144
* @return HTML markup with script tags
141
145
*/
142
- private @ NotNull String buildIncludeString (@ NotNull List <String > libraryPaths , @ NotNull Map <String , String > attrs ) {
146
+ private @ NotNull String buildIncludeString (@ NotNull List <String > libraryPaths , @ NotNull Map <String , String > attrs ,
147
+ @ NotNull Map <String , String > customAttrs ) {
143
148
StringBuilder markup = new StringBuilder ();
144
149
for (String libraryPath : libraryPaths ) {
145
150
HtmlTagBuilder builder = new HtmlTagBuilder ("script" , true , xssApi );
146
151
builder .setAttrs (attrs );
152
+ builder .setAttrs (customAttrs );
147
153
builder .setAttr ("src" , libraryPath );
148
154
markup .append (builder .build ());
149
155
}
0 commit comments