4. Can I use ‘x’ for views?
• For your HTML/XML can use
– Haml
haml :index # renders ./views/index.haml
– ERB
erb :index # renders ./views/index.erb
– Builder
content_type 'application/xml', :charset => 'utf-8’
builder :index
• For your CSS you can use
– Straight css from the ./public directory (or a subfolder thereof)
– SASS (much cooler)
content_type 'text/css', :charset => 'utf-8’
sass :stylesheet
• You can set a different view directory as well to suit
9. Deploying
1. Install Apache 2 + Passenger
2. Copy app to server and setup VirtualHost pointing to the public directory of
your app (if you don’t have one, create one…it can be empty)
3. Put this config.ru file in your app root
require 'rubygems'
require 'sinatra'
set :run, false
set :environment, ENV['RACK_ENV']
require 'app'
run Sinatra::Application
4. Go have a drink
10. Links
There’s more to learn – visit these links or just download Sinatra and start
playing
• http://www.sinatrarb.com/intro.html
• http://www.sinatrarb.com/documentation.html
• http://github.com/sinatra