Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/sr/sinatra into sr/master
Browse files Browse the repository at this point in the history
  • Loading branch information
bmizerany committed Apr 19, 2008
2 parents 40acdee + 2399905 commit 3a38dc3
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 10 deletions.
9 changes: 0 additions & 9 deletions index.html

This file was deleted.

4 changes: 3 additions & 1 deletion lib/sinatra.rb
Expand Up @@ -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
Expand Down Expand Up @@ -838,6 +839,7 @@ def self.default_options
:public => root + '/public',
:sessions => false,
:logging => true,
:haml => {}
}
end

Expand Down
52 changes: 52 additions & 0 deletions test/haml_test.rb
Expand Up @@ -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.