- Documentation: http://yardoc.org/docs/darkhelmet-sinatra-bundles
Assuming you have the following files in public:
You can bundle these files in your app like this. First, install the gem
% [sudo] gem install sinatra-bundles
And include it in your app:
Then in your view, you can use the view helpers to insert the proper script tags:
All 6 of those files will be served up in 2 files, and they'll be compressed and have headers and etags set for caching.
You can also use wildcard splats.
That will grab all files in the test directory.
That will grab all files under the test directory recursively. If you don't specify any files, it defaults to 'all files' recursively.
The defaults are pretty good. In development/test mode:
And in production mode, compression and caching are enabled
compress_bundles # => true cache_bundles # => true
To change any of these, use set/enable/disable
Check out the code for my blog for a real example: darkblog on github
What you Need
sinatra >= 1.0 packr rainpress
Note on Patches/Pull Requests
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don't break it in a future version unintentionally.
- Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
- Send me a pull request. Bonus points for topic branches.
- Patrick Hogan
- Etag support (with specs!)
- Wildcard globbing
Copyright (c) 2010 Daniel Huckstep. See LICENSE for details.