diff --git a/README.rdoc b/README.rdoc index d8c6bbfa19..ccb211a450 100644 --- a/README.rdoc +++ b/README.rdoc @@ -118,6 +118,9 @@ any strings passed to them directly. The haml gem/library is required to render HAML templates: + ## You'll need to require haml in your app + require 'haml' + get '/' do haml :index end @@ -138,6 +141,9 @@ and overridden on an individual basis. === Erb Templates + ## You'll need to require erb in your app + require 'erb' + get '/' do erb :index end @@ -148,6 +154,9 @@ Renders ./views/index.erb The builder gem/library is required to render builder templates: + ## You'll need to require builder in your app + require 'builder' + get '/' do content_type 'application/xml', :charset => 'utf-8' builder :index @@ -159,6 +168,9 @@ Renders ./views/index.builder. The sass gem/library is required to render Sass templates: + ## You'll need to require haml or sass in your app + require 'sass' + get '/stylesheet.css' do content_type 'text/css', :charset => 'utf-8' sass :stylesheet diff --git a/compat/helper.rb b/compat/helper.rb index 420c484ccf..562a75b943 100644 --- a/compat/helper.rb +++ b/compat/helper.rb @@ -1,6 +1,10 @@ require 'rubygems' require 'mocha' +require 'haml' +require 'sass' +require 'builder' + # disable warnings in compat specs. $VERBOSE = nil diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index c632753346..44e7c87bb2 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -223,23 +223,19 @@ def back ; request.referer ; end # in the template module Templates def erb(template, options={}, locals={}) - require 'erb' unless defined? ::ERB render :erb, template, options, locals end def haml(template, options={}, locals={}) - require 'haml' unless defined? ::Haml::Engine render :haml, template, options, locals end def sass(template, options={}, locals={}) - require 'sass' unless defined? ::Sass::Engine options[:layout] = false render :sass, template, options, locals end def builder(template=nil, options={}, locals={}, &block) - require 'builder' unless defined? ::Builder options, template = template, nil if template.is_a?(Hash) template = lambda { block } if template.nil? render :builder, template, options, locals diff --git a/test/haml_test.rb b/test/haml_test.rb index d26af13523..3d6ed69e09 100644 --- a/test/haml_test.rb +++ b/test/haml_test.rb @@ -1,4 +1,5 @@ require File.dirname(__FILE__) + '/helper' +require 'haml' class HAMLTest < Test::Unit::TestCase def haml_app(&block) diff --git a/test/helper.rb b/test/helper.rb index 87d394b567..153b62def8 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -14,6 +14,10 @@ require 'contest' require 'sinatra/test' +require 'haml' +require 'sass' +require 'builder' + class Sinatra::Base # Allow assertions in request context include Test::Unit::Assertions