Skip to content

Instantly share code, notes, and snippets.

@aerith
Created November 27, 2009 09:23
Show Gist options
  • Save aerith/243921 to your computer and use it in GitHub Desktop.
Save aerith/243921 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'rubygems'
require 'sinatra'
require 'haml'
require 'pathname'
get '*' do
base = Pathname.new(File.dirname(__FILE__)).parent
path = @params[:splat].first.gsub(/^\//, '')
if path !~ /\/$/ then
name = path + '.haml'
file = base + name
if file.file? && file.readable? then
return Haml::Engine.new(file.readlines.join('')).render
end
end
status 404
end
set :run => false
set :environment => :cgi
Rack::Handler::CGI.run Sinatra::Application
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment