<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -52,6 +52,16 @@ context &quot;Sass&quot; do
       body.should.equal &quot;#sass {\n  background_color: #FFF; }\n&quot;
     end
 
+    it &quot;passes :sass option to the Sass engine&quot; do
+      get '/' do
+        sass &quot;#sass\n  :background-color #FFF\n  :color #000\n&quot;, :sass =&gt; {:style =&gt; :compact}
+      end
+
+      get_it '/'
+      should.be.ok
+      body.should.equal &quot;#sass { background-color: #FFF; color: #000; }\n&quot;
+    end
+
   end
 
 end</diff>
      <filename>compat/sass_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -232,53 +232,60 @@ module Sinatra
   #   :locals       A hash with local variables that should be available
   #                 in the template
   module Templates
-    def erb(template, options={})
+    def erb(template, options={}, locals={})
       require 'erb' unless defined? ::ERB
-      render :erb, template, options
+      render :erb, template, options, locals
     end
 
-    def haml(template, options={})
+    def haml(template, options={}, locals={})
       require 'haml' unless defined? ::Haml::Engine
-      opts = options[:haml_options] || options.delete(:options) || {}
-      opts = self.class.haml.merge(opts) if self.class.respond_to?(:haml)
-      options[:haml_options] = opts
-      render :haml, template, options
+      render :haml, template, options, locals
     end
 
-    def sass(template, options={}, &amp;block)
+    def sass(template, options={}, locals={})
       require 'sass' unless defined? ::Sass::Engine
-      opts = options[:sass_options] || options.delete(:sass) || {}
-      opts = self.class.sass.merge(opts) if self.class.respond_to?(:sass)
-      options.merge! :layout =&gt; false, :sass_options =&gt; opts
-      render :sass, template, options
+      options[:layout] = false
+      render :sass, template, options, locals
     end
 
-    def builder(template=nil, options={}, &amp;block)
+    def builder(template=nil, options={}, locals={}, &amp;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
+      render :builder, template, options, locals
     end
 
   private
-    def render(engine, template, options={}) #:nodoc:
-      data   = lookup_template(engine, template, options)
-      output = __send__(&quot;render_#{engine}&quot;, template, data, options)
-      layout, data = lookup_layout(engine, options)
-      if layout
-        __send__(&quot;render_#{engine}&quot;, layout, data, options) { output }
+    def render(engine, template, options={}, locals={})
+      # merge app-level options
+      options = self.class.send(engine).merge(options) if self.class.respond_to?(engine)
+
+      # extract generic options
+      layout = options.delete(:layout)
+      layout = :layout if layout.nil? || layout == true
+      views = options.delete(:views) || self.class.views || &quot;./views&quot;
+      locals = options.delete(:locals) || locals || {}
+
+      # render template
+      data   = lookup_template(engine, template, views)
+      output = __send__(&quot;render_#{engine}&quot;, template, data, options, locals)
+
+      # render layout
+      if layout &amp;&amp; data = lookup_layout(engine, layout, views)
+        __send__(&quot;render_#{engine}&quot;, layout, data, options, {}) { output }
       else
         output
       end
     end
 
-    def lookup_template(engine, template, options={})
+    def lookup_template(engine, template, views_dir)
       case template
       when Symbol
         if cached = self.class.templates[template]
-          lookup_template(engine, cached, options)
+          lookup_template(engine, cached, views_dir)
         else
-          ::File.read(template_path(engine, template, options))
+          path = ::File.join(views_dir, &quot;#{template}.#{engine}&quot;)
+          ::File.read(path)
         end
       when Proc
         template.call
@@ -289,28 +296,17 @@ module Sinatra
       end
     end
 
-    def lookup_layout(engine, options)
-      return if options[:layout] == false
-      options.delete(:layout) if options[:layout] == true
-      template = options[:layout] || :layout
-      data     = lookup_template(engine, template, options)
-      [template, data]
+    def lookup_layout(engine, template, views_dir)
+      lookup_template(engine, template, views_dir)
     rescue Errno::ENOENT
       nil
     end
 
-    def template_path(engine, template, options={})
-      views_dir =
-        options[:views_directory] || self.options.views || &quot;./views&quot;
-      &quot;#{views_dir}/#{template}.#{engine}&quot;
-    end
-
-    def render_erb(template, data, options, &amp;block)
+    def render_erb(template, data, options, locals, &amp;block)
       original_out_buf = @_out_buf
       data = data.call if data.kind_of? Proc
 
       instance = ::ERB.new(data, nil, nil, '@_out_buf')
-      locals = options[:locals] || {}
       locals_assigns = locals.to_a.collect { |k,v| &quot;#{k} = locals[:#{k}]&quot; }
 
       src = &quot;#{locals_assigns.join(&quot;\n&quot;)}\n#{instance.src}&quot;
@@ -319,18 +315,17 @@ module Sinatra
       result
     end
 
-    def render_haml(template, data, options, &amp;block)
-      engine = ::Haml::Engine.new(data, options[:haml_options] || {})
-      engine.render(self, options[:locals] || {}, &amp;block)
+    def render_haml(template, data, options, locals, &amp;block)
+      ::Haml::Engine.new(data, options).render(self, locals, &amp;block)
     end
 
-    def render_sass(template, data, options, &amp;block)
-      engine = ::Sass::Engine.new(data, options[:sass_options] || {})
-      engine.render
+    def render_sass(template, data, options, locals, &amp;block)
+      ::Sass::Engine.new(data, options).render
     end
 
-    def render_builder(template, data, options, &amp;block)
-      xml = ::Builder::XmlMarkup.new(:indent =&gt; 2)
+    def render_builder(template, data, options, locals, &amp;block)
+      options = { :indent =&gt; 2 }.merge(options)
+      xml = ::Builder::XmlMarkup.new(options)
       if data.respond_to?(:to_str)
         eval data.to_str, binding, '&lt;BUILDER&gt;', 1
       elsif data.kind_of?(Proc)</diff>
      <filename>lib/sinatra/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -115,6 +115,22 @@ module Sinatra
       halt data
     end
 
+    # The :views_directory, :options, :haml, and :sass options are deprecated.
+    def render(engine, template, options={}, locals={}, &amp;bk)
+      if options.key?(:views_directory)
+        sinatra_warn &quot;The :views_directory option is deprecated; use :views instead.&quot;
+        options[:views] = options.delete(:views_directory)
+      end
+      [:options, engine.to_sym].each do |key|
+        if options.key?(key)
+          sinatra_warn &quot;Passing :#{key} =&gt; {} to #{engine} is deprecated; &quot; +
+                       &quot;merge options directly into hash instead.&quot;
+          options.merge! options.delete(key)
+        end
+      end
+      super(engine, template, options, locals, &amp;bk)
+    end
+
     # Throwing halt with a Symbol and the to_result convention are
     # deprecated. Override the invoke method to detect those types of return
     # values.</diff>
      <filename>lib/sinatra/compat.rb</filename>
    </modified>
    <modified>
      <diff>@@ -49,18 +49,12 @@ describe &quot;HAML Templates&quot; do
   it &quot;passes HAML options to the Haml engine&quot; do
     mock_app {
       get '/' do
-        haml &quot;!!!\n%h1 Hello World&quot;, :haml_options =&gt; {:format =&gt; :html5}
-      end
-      get '/backwards_compatible' do
-        haml &quot;!!!\n%h1 Hello World&quot;, :options =&gt; {:format =&gt; :html4}
+        haml &quot;!!!\n%h1 Hello World&quot;, :format =&gt; :html5
       end
     }
     get '/'
     assert ok?
     assert_equal &quot;&lt;!DOCTYPE html&gt;\n&lt;h1&gt;Hello World&lt;/h1&gt;\n&quot;, body
-    get '/backwards_compatible'
-    assert ok?
-    assert_match(/^&lt;!DOCTYPE html PUBLIC (.*) HTML 4.01/, body)
   end
 
   it &quot;passes default HAML options to the Haml engine&quot; do
@@ -82,7 +76,7 @@ describe &quot;HAML Templates&quot; do
         haml &quot;!!!\n%h1{:class =&gt; :header} Hello World&quot;
       end
       get '/html4' do
-        haml &quot;!!!\n%h1{:class =&gt; 'header'} Hello World&quot;, :haml_options =&gt; {:format =&gt; :html4}
+        haml &quot;!!!\n%h1{:class =&gt; 'header'} Hello World&quot;, :format =&gt; :html4
       end
     }
     get '/'</diff>
      <filename>test/haml_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -36,15 +36,7 @@ describe &quot;Sass Templates&quot; do
 
   it &quot;passes SASS options to the Sass engine&quot; do
     sass_app {
-      sass &quot;#sass\n  :background-color #FFF\n  :color #000\n&quot;, :sass_options =&gt; {:style =&gt; :compact}
-    }
-    assert ok?
-    assert_equal &quot;#sass { background-color: #FFF; color: #000; }\n&quot;, body
-  end
-
-  it &quot;passes backwards compatible SASS options to the Sass engine&quot; do
-    sass_app {
-      sass &quot;#sass\n  :background-color #FFF\n  :color #000\n&quot;, :sass =&gt; {:style =&gt; :compact}
+      sass &quot;#sass\n  :background-color #FFF\n  :color #000\n&quot;, :style =&gt; :compact
     }
     assert ok?
     assert_equal &quot;#sass { background-color: #FFF; color: #000; }\n&quot;, body
@@ -52,7 +44,7 @@ describe &quot;Sass Templates&quot; do
 
   it &quot;passes default SASS options to the Sass engine&quot; do
     mock_app {
-      set :sass, {:style =&gt; :compact } # default Sass style is :nested
+      set :sass, {:style =&gt; :compact} # default Sass style is :nested
       get '/' do
         sass &quot;#sass\n  :background-color #FFF\n  :color #000\n&quot;
       end
@@ -69,10 +61,10 @@ describe &quot;Sass Templates&quot; do
         sass &quot;#sass\n  background-color: #FFF\n  color: #000\n&quot;
       end
       get '/raised' do
-        sass &quot;#sass\n  :background-color #FFF\n  :color #000\n&quot;, :sass_options =&gt; {:style =&gt; :expanded } # retains global attribute_syntax settings
+        sass &quot;#sass\n  :background-color #FFF\n  :color #000\n&quot;, :style =&gt; :expanded # retains global attribute_syntax settings
       end
       get '/expanded_normal' do
-        sass &quot;#sass\n  :background-color #FFF\n  :color #000\n&quot;, :sass_options =&gt; {:style =&gt; :expanded, :attribute_syntax =&gt; :normal }
+        sass &quot;#sass\n  :background-color #FFF\n  :color #000\n&quot;, :style =&gt; :expanded, :attribute_syntax =&gt; :normal
       end
     }
     get '/'
@@ -82,6 +74,5 @@ describe &quot;Sass Templates&quot; do
     get '/expanded_normal'
     assert ok?
     assert_equal &quot;#sass {\n  background-color: #FFF;\n  color: #000;\n}\n&quot;, body
-
   end
 end</diff>
      <filename>test/sass_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/helper'
 describe 'Templating' do
   def render_app(&amp;block)
     mock_app {
-      def render_test(template, data, options, &amp;block)
+      def render_test(template, data, options, locals, &amp;block)
         inner = block ? block.call : ''
         data + inner
       end</diff>
      <filename>test/templates_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>5b2dfebbf0477b3ab37a44b33361fc9ab4651ad6</id>
    </parent>
  </parents>
  <author>
    <name>Ryan Tomayko</name>
    <email>rtomayko@gmail.com</email>
  </author>
  <url>http://github.com/bmizerany/sinatra/commit/49adaa53629e37d4711ad3ae7edfe67992ca3618</url>
  <id>49adaa53629e37d4711ad3ae7edfe67992ca3618</id>
  <committed-date>2009-03-31T01:58:47-07:00</committed-date>
  <authored-date>2009-03-27T10:00:33-07:00</authored-date>
  <message>Sane template options [#191]

* The options hash now takes the :views, :layout, and :locals
  options but also any template-specific options. The generic
  options are removed before calling the template specific render
  method.

* The haml &quot;:options&quot; and &quot;:haml&quot; options are deprecated. These
  should be merged in directly with the options hash.

* The sass &quot;:sass&quot; option is deprecated. Merge directly with the
  options hash instead.

* All template engines have an app-level option named the same as
  their engine (erb, haml, sass, etc.). This must be a hash and is
  merged with the options passed to the render method.

* The :views_directory option is deprecated; renamed :views.</message>
  <tree>d1c4924cfc882e7d9db44b306ef5e48145e50222</tree>
  <committer>
    <name>Ryan Tomayko</name>
    <email>rtomayko@gmail.com</email>
  </committer>
</commit>
