public
Description: HTML Abstraction Markup Language - A Markup Haiku
Homepage: http://haml.hamptoncatlin.com
Clone URL: git://github.com/nex3/haml.git
Merged Nate Vack's ActionViewMods changes to stable.


git-svn-id: svn://hamptoncatlin.com/haml/tags/stable@466 
7063305b-7217-0410-af8c-cdc13e5119b9
nex3 (author)
Sat Mar 31 16:27:05 -0700 2007
commit  942815a09c68d42d2d71938d566b61031fe04519
tree    5760e32d5f4903af956c35f9b1c51c43f760f9aa
parent  76c92aea84d5a9235b47570e1a16a24fef297b0e
...
8
9
10
11
 
12
13
14
15
16
 
17
18
19
...
186
187
188
189
190
191
192
193
194
195
196
...
226
227
228
 
229
230
231
...
235
236
237
238
239
240
241
242
...
8
9
10
 
11
12
13
14
15
 
16
17
18
19
...
186
187
188
 
 
 
 
 
189
190
191
...
221
222
223
224
225
226
227
...
231
232
233
 
 
234
235
236
0
@@ -8,12 +8,12 @@ module Haml
0
   module Helpers
0
     self.extend self
0
     
0
- @@action_view = false
0
+ @@action_view_defined = defined?(ActionView)
0
     @@force_no_action_view = false
0
 
0
     # Returns whether or not ActionView is installed on the system.
0
     def self.action_view?
0
- @@action_view
0
+ @@action_view_defined
0
     end
0
 
0
     # Isolates the whitespace-sensitive tags in the string and uses preserve
0
@@ -186,11 +186,6 @@ module Haml
0
     end
0
     
0
     private
0
-
0
- # Sets whether or not ActionView is installed on the system.
0
- def self.action_view(value) # :nodoc:
0
- @@action_view = value
0
- end
0
 
0
     # Gets a reference to the current Haml::Buffer object.
0
     def buffer
0
@@ -226,6 +221,7 @@ module Haml
0
       end
0
       result.to_s
0
     end
0
+ alias_method :capture_erb_with_buffer, :capture_haml_with_buffer
0
 
0
     # Returns whether or not the current template is a Haml template.
0
     #
0
@@ -235,8 +231,6 @@ module Haml
0
     def is_haml?
0
       @haml_stack ? @haml_stack.size > 0 : false
0
     end
0
-
0
- include ActionViewMods if self.const_defined? "ActionViewMods"
0
   end
0
 end
0
 
...
9
10
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
36
37
38
39
 
 
 
40
41
42
43
 
44
45
46
47
 
 
 
 
 
48
49
50
...
54
55
56
57
 
58
59
60
61
62
 
 
 
 
 
63
64
65
66
67
68
69
 
70
71
 
72
73
74
75
76
77
 
 
 
 
 
78
 
79
80
81
82
...
9
10
11
 
 
 
 
 
 
 
 
12
13
14
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
17
18
19
20
21
 
22
23
24
 
 
25
26
27
28
29
30
31
32
...
36
37
38
 
39
40
41
42
 
 
43
44
45
46
47
48
49
50
51
52
53
 
54
55
 
56
57
58
 
 
 
 
59
60
61
62
63
64
65
66
67
68
 
0
@@ -9,42 +9,24 @@ rescue LoadError
0
 end
0
 
0
 if action_view_included
0
- class ActionView::Base
0
- alias_method :old_concat, :concat unless instance_methods.include? "old_concat"
0
- alias_method :old_form_tag, :form_tag unless instance_methods.include? "old_form_tag"
0
-
0
- alias_method :old_form_for, :form_for unless instance_methods.include? "old_form_for"
0
- end
0
-
0
- module Haml
0
+ module ActionView
0
+ # This overrides various helpers in ActionView
0
+ # to make them work more effectively with Haml.
0
     module Helpers
0
- # This module overrides various helpers in ActionView
0
- # to make them work more effectively with Haml.
0
- # It also defines several helper methods,
0
- # available from a Haml template,
0
- # which are only useful within the context of ActionView.
0
- # It's not available unless ActionView is installed.
0
- #
0
- #--
0
- # Methods in this module should be nodoc'd.
0
- #++
0
- module ActionViewMods
0
- def self.included(othermod) # :nodoc:
0
- othermod.class_eval do
0
- action_view(true)
0
- alias_method :capture_erb_with_buffer, :capture_haml_with_buffer
0
- end
0
- end
0
-
0
- def concat(string, binding = nil) # :nodoc:
0
+ # :stopdoc:
0
+ module TextHelper
0
+ def concat_with_haml(string, binding = nil)
0
           if is_haml?
0
             buffer.buffer.concat(string)
0
           else
0
- old_concat(string, binding)
0
+ concat_without_haml(string, binding)
0
           end
0
         end
0
-
0
- def form_tag(url_for_options = {}, options = {}, *parameters_for_url, &proc) # :nodoc:
0
+ alias_method_chain :concat, :haml
0
+ end
0
+
0
+ module FormTagHelper
0
+ def form_tag_with_haml(url_for_options = {}, options = {}, *parameters_for_url, &proc)
0
           if block_given? && is_haml?
0
             oldproc = proc
0
             proc = bind_proc do |*args|
0
@@ -54,29 +36,33 @@ if action_view_included
0
               tab_down
0
             end
0
           end
0
- res = old_form_tag(url_for_options, options, *parameters_for_url, &proc) + "\n"
0
+ res = form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc) + "\n"
0
           concat "\n" if block_given? && is_haml?
0
           res
0
         end
0
-
0
- def form_for(object_name, *args, &proc) # :nodoc:
0
+ alias_method_chain :form_tag, :haml
0
+ end
0
+
0
+ module FormHelper
0
+ def form_for_with_haml(object_name, *args, &proc)
0
           if block_given? && is_haml?
0
             oldproc = proc
0
             proc = bind_proc do |*args|
0
               tab_up
0
               oldproc.call(*args)
0
               tab_down
0
- end
0
+ end
0
           end
0
- old_form_for(object_name, *args, &proc)
0
+ form_for_without_haml(object_name, *args, &proc)
0
           concat "\n" if block_given? && is_haml?
0
         end
0
-
0
- def generate_content_class_names
0
- controller.controller_name + " " + controller.action_name
0
- end
0
+ alias_method_chain :form_for, :haml
0
+ end
0
+
0
+ def generate_content_class_names
0
+ controller.controller_name + " " + controller.action_name
0
       end
0
+ # :startdoc:
0
     end
0
   end
0
 end
0
-
...
62
63
64
65
 
66
67
 
68
69
70
...
62
63
64
 
65
66
 
67
68
69
70
0
@@ -62,9 +62,9 @@ class HelperTest < Test::Unit::TestCase
0
 
0
     begin
0
       ActionView::Base.new.render(:inline => "<%= concat('foo') %>")
0
- rescue ArgumentError
0
+ rescue ArgumentError, NameError
0
       proper_behavior = true
0
- end
0
+ end
0
     assert(proper_behavior)
0
   end
0
   

Comments

    No one has commented yet.