Skip to content

Instantly share code, notes, and snippets.

@oshow
Created November 16, 2011 09:29
Show Gist options
  • Save oshow/1369670 to your computer and use it in GitHub Desktop.
Save oshow/1369670 to your computer and use it in GitHub Desktop.
for Rubyist Magazine 0036
# encoding: utf-8
require 'rubygems'
require 'sinatra/base'
require 'sinatra/reloader'
require 'rack/rewrite'
require 'haml'
class App < Sinatra::Base
enable :inline_templates
enable :logging
configure :development do
set :server, "webrick"
register Sinatra::Reloader
end
use Rack::Rewrite do
rewrite %r{^/song_for/(.*)}, '/name/$1'
end
get '/' do
@title = "Top"
haml "My Way"
end
get '/name/:name' do
@name = params[:name]
@title = "Song for #{@name}"
haml "#{@name}'s Way"
end
end
App.run!
__END__
@@ layout
!!! 5
%html
%head
%title= @title
%body
%h1= @title
%div= yield
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment