Permalink
Browse files

Merge branch 'master' of git://github.com/sr/sinatra into sr/master

  • Loading branch information...
bmizerany committed Apr 19, 2008
2 parents 40acdee + 2399905 commit 3a38dc3491cdb42ef6074b396a6b8d4977e417b8
Showing with 55 additions and 10 deletions.
  1. +0 −9 index.html
  2. +3 −1 lib/sinatra.rb
  3. +52 −0 test/haml_test.rb
View
@@ -1,9 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-<head>
-<title>Your Page Title</title>
-<meta http-equiv="REFRESH" content="0;url=http://sinatrarb.com"></HEAD>
-<BODY>
-This site has <a href="http:://sinatrarb.com">moved</a>.
-</BODY>
-</HTML>
View
@@ -604,7 +604,8 @@ def haml(content, options={})
private
def render_haml(content, options = {}, &b)
- ::Haml::Engine.new(content).render(options[:scope] || self, options[:locals] || {}, &b)
+ haml_options = (options[:options] || {}).merge(Sinatra.options.haml)
+ ::Haml::Engine.new(content, haml_options).render(options[:scope] || self, options[:locals] || {}, &b)
end
end
@@ -838,6 +839,7 @@ def self.default_options
:public => root + '/public',
:sessions => false,
:logging => true,
+ :haml => {}
}
end
View
@@ -178,4 +178,56 @@
end
+ describe 'Options passed to the HAML interpreter' do
+ setup do
+ Sinatra.application = nil
+ end
+
+ specify 'are empty be default' do
+
+ get '/' do
+ haml 'foo'
+ end
+
+ Haml::Engine.expects(:new).with('foo', {}).returns(stub(:render => 'foo'))
+
+ get_it '/'
+ should.be.ok
+
+ end
+
+ specify 'can be configured by passing :options to haml' do
+
+ get '/' do
+ haml 'foo', :options => {:format => :html4}
+ end
+
+ Haml::Engine.expects(:new).with('foo', {:format => :html4}).returns(stub(:render => 'foo'))
+
+ get_it '/'
+ should.be.ok
+
+ end
+
+ specify 'can be configured using set_option :haml' do
+
+ configure do
+ set_option :haml, :format => :html4,
+ :escape_html => true
+ end
+
+ get '/' do
+ haml 'foo'
+ end
+
+ Haml::Engine.expects(:new).with('foo', {:format => :html4,
+ :escape_html => true}).returns(stub(:render => 'foo'))
+
+ get_it '/'
+ should.be.ok
+
+ end
+
+ end
+
end

0 comments on commit 3a38dc3

Please sign in to comment.