AssetsLedger
Keep track of JS/CSS dependencies and makes sure they are only included once.
Installation
Add this line to your application's Gemfile:
gem 'assets_ledger'
And then execute:
$ bundle
Or install it yourself as:
$ gem install assets_ledger
Usage
ledger = AssetsLedger::Ledger.new
ledger.add_js('path/to/js')
ledger.add_css('path/to/css')
# You can add many dependencies at once
ledger.add_js('/js/jquery.js', 'js/jquery.datatables.js')
# or pass an array
js_dependencies = ['/js/jquery.js', 'js/jquery.datatables.js']
ledger.add_js(js_dependencies)
if you use Rails you can generate the include tags by:
# In application.html.erb
stylesheet_link_tag *ledger.css_dependencies
# ...
javascript_include_tag *ledger.js_dependencies
Contributing
- Fork it ( https://github.com/trialbee/assets_ledger/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request