Patches: Browse | Submit New | Admin

[#23739] Rails 2.3 syntax change

Date:
2009-01-29 13:35
Priority:
3
Submitted By:
Jeff Wigal (jwigal)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
Rails 2.3 syntax change

Detailed description
Would you be willing to apply the following patch for nested_layouts?
We have been using the plugin in an upcoming project and it works
great.

The idea for this fix came here:

http://github.com/mislav/will_paginate/commit/787555f477e7bd71f83b651e8611a7a53026c2c5

* Rails 2.2 syntax for render_file takes the :use_full_path parameter, and
* the second parameter in the concat method is no longer in use for Rails 2.3

Thanks in advance--


--- /a/nested_layouts/lib/nested_layouts.rb	2009-01-29 07:53:40.000000000 -0500
+++ /b/nested_layouts/lib/nested_layouts.rb	2009-01-29 08:16:28.000000000 -0500
@@ -1,3 +1,4 @@
+require 'action_pack/version'
 module ActionView #:nodoc:
   module Helpers #:nodoc:
     module NestedLayoutsHelper
@@ -10,17 +11,24 @@
       def inside_layout(layout, &block)
         layout = layout.include?('/') ? layout : "layouts/#{layout}"
         @template.instance_variable_set('@content_for_layout', capture(&block))
-        concat(
-          @template.render( :file => layout, :user_full_path => true ),
-          block.binding
-        )
+        if ActionPack::VERSION::STRING.to_f >= 2.2
+          concat( @template.render( :file => layout, :use_full_path => true ))
+        else
+          concat( @template.render( :file => layout, :use_full_path => true ), block.binding)
+        end
       end
 
       # Wrap part of the template into inline layout.
       # Same as +inside_layout+ but takes layout template content rather than layout template name.
       def inside_inline_layout(template_content, &block)
         @template.instance_variable_set('@content_for_layout', capture(&block))
-        concat( @template.render( :inline => template_content ), block.binding )
+        if ActionPack::VERSION::STRING.to_f >= 2.2
+          concat(
+            @template.render( :file => layout, :use_full_path => true )
+          )
+        else
+          concat(@template.render( :file => layout, :use_full_path => true ), block.binding )
+        end
       end
     end
   end

Add A Comment: Notepad

Please login


Followup

No Followups Have Been Posted

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item