Sinatra::Assets

Methods for working with assets like images, links etc.

Getting Started

To start caching your app’s ouput, just require and register the extension in your sub-classed Sinatra app:

require 'sinatra/assets'

class YourApp < Sinatra::Base

  register(Sinatra::Assets)

  <snip...>

end

In your “classic” Sinatra app, you just require the extension and set some key settings, like this:

require 'rubygems'
require 'sinatra'
require 'sinatra/assets'

# NB! you need to set the root of the app first
set :root, '/path/2/the/root/of/your/app'
set :public, '/path/2/public'

<snip...>

See the method definitions for further information.

Dependencies:

This extension depends on the following:

Ruby Gems:

  • alt/rext/hash/conversions

    • Methods used:

      • :to_html_attributes

Extensions:

None

Configurations:

None

Routes:

None

Code Inspirations:

  • The Chicago gem by Thumble Monks

  • The ActiveSupport gem by DHH & Rails Core Team

  • sinatra-url-for by Eric Kidd

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.

Copyright © 2010 kematzy. See LICENSE for details.