Skip to content

Instantly share code, notes, and snippets.

@wmorgan
Created February 18, 2011 01:37
Show Gist options
  • Save wmorgan/833102 to your computer and use it in GitHub Desktop.
Save wmorgan/833102 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'sinatra'
$conts = []
def link_to title, &b
id = $conts.size
$conts[id] = b
"<a href='/next/#{id}'>#{title}</a>"
end
get '/hi', :provides => 'html' do
"hello world " + link_to("click here") { "thanks for clicking!" }
end
get '/next/:id', :provides => 'html' do |id|
$conts[id.to_i].call
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment