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

Adding Jammit::Packager#includes? to detect existence of compiled assets. #246

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

andrewhao
Copy link

This allows us to detect the existence of a packaged asset at runtime, and gives us the ability to determine whether to call the Jammit stylesheet/javascript helper or the default Rails tag helpers.

Andrew Hao added 2 commits March 3, 2013 10:37
… to determine whether an asset can be expected in Jammit.
@jashkenas
Copy link
Member

Tell us a bit about your use case, please.

@andrewhao
Copy link
Author

@jashkenas: I'm stuck in a Rails 2 app which on a per-controller basis loads in a custom stylesheet/script tag. Say I need to load "admin.js".

Now in a content_for block in my view, I had simply been rendering javascript_include_tag :admin. I'd like to basically render include_javascripts :admin and use the Jammit package if it exists, and otherwise fall back to javascript_include_tag if it doesn't.

@jashkenas
Copy link
Member

Sounds pretty special case. Can't you just define these custom asset packages, and use them? Too many? Even to do in a loop in ERB in your assets.yml?

@andrewhao
Copy link
Author

@jashkenas Yep, those are all valid alternatives. I just thought it'd be nice to add an extra layer of abstraction so I didn't have to know about Jammit configuration implementation.

What are your concerns? I could perhaps extract this method into a new Jammit::Configuration object if you're concerned about model bloat.

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

2 participants