Closed mberndt123 closed 6 years ago
Thanks for the feedback! Agree that there is definitely some sub-optimal stuff here. I'd love any PRs to address this. :)
Thanks a ton! This has been released as 2.6.3
and will be available shortly. Bonus points if you update: https://github.com/webjars/webjars/blob/master/app/views/documentation.scala.html :)
Hey @jamesward, allright, I hope I'll get around to that tomorrow
Hi,
I'm sorry for the inflammatory title, but I think I have good reasons to hold this position.
@Html(webJarsUtil.script("foo", "index.js"))
. But for the former it's difficult, because "index.js" is can also be understood to be a partial path to the latter, hence you get a MultipleMatchesException. You can work around it by specifying the version number, but then things will break when you upgrade the library. The real problem here is that there's no convenient way to separate the two different things that webJarsUtil does, which are 1. locating an asset and 2. transforming it into something useful, like a script or css element. You have to do something like@Html(webJarUtils.script(webJarUtils.localOrCdnUrl(webJarUtils.fullPath("foo", "index.js"))))
to address my use case (I did hit this case in practice a while ago).WebJarsUtil.locate(String, String)
is also inefficient since it callsWebJarAssetsLocator.locate(String, String)
, which callsWebJarAssetsLocator.filterPathByIndex
which traverses the complete list of all assets in all webjars, which can be slow.Html
type. This forces users to write@Html(webJarsUtil.css(…))
rather than just@webJarsUtil.css(…)
, and using@Html
is generally discouraged.*withParams
methods (scriptWithParams
etc.) don't escape these parameters properly, so they're not safe to use.WebJarAssetLocator.getFullPathExact
As far as I can see, there's no way to fix this short of essentially rewriting WebJarsUtil.
Html
rather thanString
and will also escape special characters correctly).WebjarAsset
) which is returned from thelocate
andfullPath
methods. Methods likelocalOrCdnUrl
,tag
,script
,path
should be moved to this new type and operate on the previously located path. This separates more clearly the two separate steps of 1. locating an asset and 2. transforming it to useful Html.I'd be willing to implement this (WebJarsUtil isn't that huge after all), but first I'd like to hear what you think about this proposal.