Sinatra::CSS

A Sinatra Extension that makes working with CSS easy.

Installation

#  Add RubyGems.org (former Gemcutter) to your RubyGems sources 
$  gem sources -a http://rubygems.org

$  (sudo)? gem install sinatra-css

Dependencies

This Gem depends upon the following:

Runtime:

  • sinatra ( >= 1.0.a )
  • sinatra-tags ( >= 0.1.0 )
  • sinatra-outputbuffer ( >= 0.1.0 )
  • sinatra-basics ( >= 0.5.0 )

Optionals:

  • sinatra-settings (>= 0.1.1) # to view default settings in a browser display.
  • sinatra-logger (>= 0.1.0) # to capture error messages in the log file.

Development & Tests:

  • sinatra-tests (>= 0.1.6)
  • rspec (>= 1.3.0 )
  • rack-test (>= 0.5.3)
  • rspec_hpricot_matchers (>= 0.1.0)

Getting Started

To start using Sinatra::CSS, just require and register the extension in your App...

require 'sinatra/css'

class YourApp < Sinatra::Base
register(Sinatra::CSS)

<snip...>

end

You then get access to 6 useful helper methods:

css()

This method serves two purposes:

a) Return a stylesheet tag with the path given.

css('/css/style.css') # => 

<link rel="stylesheet" href="/css/style.css" media="screen" type="text/css" charset="utf-8">

css('style.css', :media => :print) # => 

<link rel="stylesheet" href="/style.css" media="print" type="text/css" charset="utf-8">

b) When passed a block, a