Created
October 16, 2008 15:29
-
-
Save technicalpickles/17163 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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