GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Fork of nex3/haml
Description: HTML Abstraction Markup Language - A Markup Haiku
Homepage: http://haml.hamptoncatlin.com
Clone URL: git://github.com/chriseppstein/haml.git
Tagging 1.5.1.


git-svn-id: svn://hamptoncatlin.com/haml/tags/rel_1-5-1@468 
7063305b-7217-0410-af8c-cdc13e5119b9
nex3 (author)
Sat Mar 31 16:29:12 -0700 2007
commit  524d4dbb4bbe3dc12d233e50e33671839096a40d
tree    9207b2e99cb6c076ebc8f64a30896098f5e61a98
parent  fb95cc2d21e75ae7c910eb68f96e4db6cbbf339c
...
1
 
...
 
1
0
@@ -1 +1 @@
0
-1.5.0
0
+1.5.1
...
129
130
131
132
133
134
135
136
137
138
139
140
141
...
149
150
151
 
 
 
 
 
 
 
 
152
153
154
...
309
310
311
312
313
 
 
 
314
315
316
...
589
590
591
592
 
593
594
595
...
129
130
131
 
 
 
 
 
 
 
132
133
134
...
142
143
144
145
146
147
148
149
150
151
152
153
154
155
...
310
311
312
 
 
313
314
315
316
317
318
...
591
592
593
 
594
595
596
597
0
@@ -129,13 +129,6 @@ END
0
         }
0
       }
0
 
0
- unless @options[:suppress_eval]
0
- @options[:filters].merge!({
0
- 'erb' => ERB,
0
- 'ruby' => Haml::Filters::Ruby
0
- })
0
- end
0
-
0
       if !NOT_LOADED.include? 'redcloth'
0
         @options[:filters].merge!({
0
           'redcloth' => RedCloth,
0
@@ -149,6 +142,14 @@ END
0
 
0
       @options.rec_merge! options
0
 
0
+ unless @options[:suppress_eval]
0
+ @options[:filters].merge!({
0
+ 'erb' => ERB,
0
+ 'ruby' => Haml::Filters::Ruby
0
+ })
0
+ end
0
+ @options[:filters].rec_merge! options[:filters] if options[:filters]
0
+
0
       @precompiled = @options[:precompiled]
0
 
0
       @template = template.strip #String
0
@@ -309,8 +310,9 @@ END
0
       when SILENT_SCRIPT
0
         sub_line = line[1..-1]
0
         unless sub_line[0] == SILENT_COMMENT
0
- push_silent(sub_line, true)
0
- if @block_opened && !mid_block_keyword?(line)
0
+ mbk = mid_block_keyword?(line)
0
+ push_silent(sub_line, !mbk)
0
+ if (@block_opened && !mbk) || line[1..-1].split(' ', 2)[0] == "case"
0
             push_and_tabulate([:script])
0
           end
0
         end
0
@@ -589,7 +591,7 @@ END
0
         warn(FLAT_WARNING) if flattened && !defined?(Test::Unit)
0
 
0
         value_exists = !value.empty?
0
- attributes_hash = "nil" unless attributes_hash
0
+ attributes_hash = "nil" if attributes_hash.nil? || @options[:suppress_eval]
0
         object_ref = "nil" unless object_ref
0
 
0
         if @block_opened
...
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
-
...
57
58
59
 
 
 
 
 
 
 
 
 
60
61
62
...
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
0
@@ -57,6 +57,15 @@ class EngineTest < Test::Unit::TestCase
0
 
0
   def test_stop_eval
0
     assert_equal("", render("= 'Hello'", :suppress_eval => true))
0
+ assert_equal("<div id='foo' />\n", render("#foo{:yes => 'no'}/", :suppress_eval => true))
0
+
0
+ begin
0
+ assert_equal("", render(":ruby\n puts 'hello'", :suppress_eval => true))
0
+ rescue Haml::HamlError => err
0
+ caught = true
0
+ assert_equal('Filter "ruby" is not defined!', err.message)
0
+ end
0
+ assert(caught, "Rendering a ruby filter without evaluating didn't throw an error!")
0
   end
0
 
0
   def test_attr_wrapper
...
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
   
...
41
42
43
 
 
...
41
42
43
44
45
0
@@ -41,3 +41,5 @@ stuff followed by whitespace
0
   Woah a period.
0
 <![endif]-->
0
 testtest
0
+<foo />
0
+<foo />
...
38
39
40
41
42
 
 
 
 
 
 
 
 
 
 
 
...
38
39
40
 
41
42
43
44
45
46
47
48
49
50
51
52
0
@@ -38,4 +38,14 @@
0
 /[if gte IE5.2]
0
   Woah a period.
0
 = "test" |
0
- "test" |
0
\ No newline at end of file
0
+ "test" |
0
+- case :foo
0
+- when :bar
0
+ %bar/
0
+- when :foo
0
+ %foo/
0
+- case :foo
0
+ - when :bar
0
+ %bar/
0
+ - when :foo
0
+ %foo/

Comments

    No one has commented yet.