Permalink
Browse files

Merge branch 'compiling-tilt' into master

This upgrades Tilt to 0.7 and adds compiled template support for
ERB, Erubis, Haml, and Builder.
  • Loading branch information...
2 parents ae34a6f + 3e9f46d commit 19efdf869984071b801d02795ed70d5e31aa3e62 @rtomayko rtomayko committed Mar 4, 2010
Showing with 255 additions and 94 deletions.
  1. +10 −0 lib/sinatra/base.rb
  2. +243 −93 lib/sinatra/tilt.rb
  3. +2 −1 test/templates_test.rb
View
@@ -8,6 +8,12 @@
# require tilt if available; fall back on bundled version.
begin
require 'tilt'
+ if Tilt::VERSION < '0.7'
+ warn "WARN: sinatra requires tilt >= 0.7; you have #{Tilt::VERSION}. " +
+ "loading bundled version..."
+ Object.send :remove_const, :Tilt
+ raise LoadError
+ end
rescue LoadError
require 'sinatra/tilt'
end
@@ -289,11 +295,15 @@ def back ; request.referer ; end
# :locals A hash with local variables that should be available
# in the template
module Templates
+ include Tilt::CompileSite
+
def erb(template, options={}, locals={})
+ options[:outvar] = '@_out_buf'
render :erb, template, options, locals
end
def erubis(template, options={}, locals={})
+ options[:outvar] = '@_out_buf'
render :erubis, template, options, locals
end
Oops, something went wrong.

0 comments on commit 19efdf8

Please sign in to comment.