Skip to content

Instantly share code, notes, and snippets.

@technicalpickles
Created October 16, 2008 15:29
Show Gist options
  • Save technicalpickles/17163 to your computer and use it in GitHub Desktop.
Save technicalpickles/17163 to your computer and use it in GitHub Desktop.
require "rubygems"
require "sinatra"
helpers do
def stylesheet_link_tag(*sources)
fragments = sources.map do |source|
"<link href='/stylesheets/#{source}.css' rel='stylesheet' type='text/css' />"
end
fragments.join
end
end
layout 'layout.haml'
get '/*' do
path = params[:splat].join('/')
template = determine_template(path)
template ? haml(template) : "Wasn't sure what to do with #{path}"
end
def determine_template(path)
return path.to_sym if File.exists?(template_for(path))
path += "/index"
return path.to_sym if File.exists?(template_for(path))
end
def template_for(path)
"views/#{path}.haml"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment