Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor WebJarsUtil #80

Merged
merged 2 commits into from
Jan 11, 2018
Merged

refactor WebJarsUtil #80

merged 2 commits into from
Jan 11, 2018

Conversation

mberndt123
Copy link
Contributor

@mberndt123 mberndt123 commented Jan 10, 2018

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 of WebJarsUtil's methods to apply. I would suggest fullPath as I think it's probably the most robust way to locate a Webjar asset, it doesn't break as easily as locate 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.

@jamesward
Copy link
Member

Thanks! This looks really great.

One last request, can you update the code in the test-project to take advantage of these changes?

@mberndt123
Copy link
Contributor Author

done

@jamesward jamesward merged commit 03c7e84 into webjars:master Jan 11, 2018
@mberndt123
Copy link
Contributor Author

Cool, thanks for merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants