Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey @jamesward,
as discussed in #79, I have rewritten WebJarsUtil. It is now significantly shorter and more flexible as it doesn't conflate how to locate an asset with what to do with it once it's found.
Rather than
@Html(webJarUtils.script(webJarUtils.localOrCdnUrl(webJarUtils.fullPath("bar", "qux.js"))))
you can now write@webJarUtils.fullPath("bar", "qux.js").script()
. Note that not only is this much easier but also that the@Html(…)
stuff goes away.Some things are a little longer now, for instance what used to be
@Html(webJarsUtil.script("foo", "bar.js")
is now@webJarsUtil.locate("foo", "bar.js").script()
(4 characters longer), but I think the added flexibility is worth it. To make things even more terse, we could rename one ofWebJarsUtil
's methods toapply
. I would suggestfullPath
as I think it's probably the most robust way to locate a Webjar asset, it doesn't break as easily aslocate
when you e. g. upgrade a library.If additional attributes are specified, they are now escaped correctly, making the library safer to use.
If a webjar is not found in dev/test mode, the library will now just blow up rather than generate a comment, making errors harder to miss.
Take a look and let me know what you think.