public
Rubygem
Description: Liquid markup language. Save, customer facing template language for flexible web apps.
Homepage: http://www.liquidmarkup.org
Clone URL: git://github.com/tobi/liquid.git
Click here to lend your support to: liquid and make a donation at www.pledgie.com !
Enable rails 2.1.x compaitibility by allowing the render method to accept an 
ActionView::Template object.

This seems to complete the earlier 'ugly hack' for rails 2.1.x compatibility
moklett (author)
Mon Sep 22 06:48:15 -0700 2008
commit  3bfde37a53edc8502052696e53fde3758686b718
tree    9bb3ab7c5b58c09617ca4fa90ecb66dcefe62f3a
parent  24bf446b0e789865370bfe248c2cfe44602afd61
...
11
12
13
14
 
15
16
17
 
 
 
 
 
 
 
 
 
18
19
20
21
22
23
 
24
25
26
...
11
12
13
 
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
32
33
34
35
0
@@ -11,16 +11,25 @@ class LiquidView
0
   end
0
   
0
 
0
-  def render(template, local_assigns)
0
+  def render(template, local_assigns_for_rails_less_than_2_1_0 = nil)
0
     @action_view.controller.headers["Content-Type"] ||= 'text/html; charset=utf-8'
0
     assigns = @action_view.assigns.dup
0
     
0
+    # template is a Template object in Rails >=2.1.0, a source string previously.
0
+    if template.respond_to? :source
0
+      source = template.source
0
+      local_assigns = template.locals
0
+    else
0
+      source = template
0
+      local_assigns = local_assigns_for_rails_less_than_2_1_0
0
+    end
0
+
0
     if content_for_layout = @action_view.instance_variable_get("@content_for_layout")
0
       assigns['content_for_layout'] = content_for_layout
0
     end
0
     assigns.merge!(local_assigns)
0
     
0
-    liquid = Liquid::Template.parse(template)
0
+    liquid = Liquid::Template.parse(source)
0
     liquid.render(assigns, :filters => [@action_view.controller.master_helper_module], :registers => {:action_view => @action_view, :controller => @action_view.controller})
0
   end
0
 

Comments