haml-edge 2.1.21 → 2.1.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/EDGE_GEM_VERSION +1 -1
  2. data/FAQ.md +142 -0
  3. data/{README.rdoc → README.md} +141 -141
  4. data/Rakefile +29 -17
  5. data/VERSION +1 -1
  6. data/lib/haml/buffer.rb +63 -27
  7. data/lib/haml/engine.rb +103 -80
  8. data/lib/haml/error.rb +7 -7
  9. data/lib/haml/exec.rb +80 -26
  10. data/lib/haml/filters.rb +106 -40
  11. data/lib/haml/helpers/action_view_extensions.rb +34 -39
  12. data/lib/haml/helpers/action_view_mods.rb +132 -139
  13. data/lib/haml/helpers.rb +207 -153
  14. data/lib/haml/html.rb +40 -21
  15. data/lib/haml/precompiler.rb +2 -0
  16. data/lib/haml/shared.rb +34 -3
  17. data/lib/haml/template/patch.rb +1 -1
  18. data/lib/haml/template/plugin.rb +0 -2
  19. data/lib/haml/template.rb +5 -0
  20. data/lib/haml/util.rb +136 -1
  21. data/lib/haml/version.rb +16 -4
  22. data/lib/haml.rb +502 -481
  23. data/lib/sass/css.rb +106 -68
  24. data/lib/sass/engine.rb +55 -22
  25. data/lib/sass/environment.rb +52 -21
  26. data/lib/sass/error.rb +23 -12
  27. data/lib/sass/files.rb +27 -0
  28. data/lib/sass/plugin/merb.rb +2 -2
  29. data/lib/sass/plugin/rails.rb +0 -2
  30. data/lib/sass/plugin.rb +32 -23
  31. data/lib/sass/repl.rb +7 -0
  32. data/lib/sass/script/bool.rb +9 -5
  33. data/lib/sass/script/color.rb +87 -1
  34. data/lib/sass/script/funcall.rb +23 -2
  35. data/lib/sass/script/functions.rb +93 -44
  36. data/lib/sass/script/lexer.rb +33 -3
  37. data/lib/sass/script/literal.rb +93 -1
  38. data/lib/sass/script/node.rb +14 -0
  39. data/lib/sass/script/number.rb +128 -4
  40. data/lib/sass/script/operation.rb +16 -1
  41. data/lib/sass/script/parser.rb +51 -21
  42. data/lib/sass/script/string.rb +7 -4
  43. data/lib/sass/script/unary_operation.rb +14 -1
  44. data/lib/sass/script/variable.rb +12 -1
  45. data/lib/sass/script.rb +26 -5
  46. data/lib/sass/tree/attr_node.rb +46 -9
  47. data/lib/sass/tree/comment_node.rb +41 -1
  48. data/lib/sass/tree/debug_node.rb +8 -0
  49. data/lib/sass/tree/directive_node.rb +20 -0
  50. data/lib/sass/tree/file_node.rb +12 -0
  51. data/lib/sass/tree/for_node.rb +15 -0
  52. data/lib/sass/tree/if_node.rb +22 -0
  53. data/lib/sass/tree/mixin_def_node.rb +12 -1
  54. data/lib/sass/tree/mixin_node.rb +13 -0
  55. data/lib/sass/tree/node.rb +136 -6
  56. data/lib/sass/tree/rule_node.rb +66 -7
  57. data/lib/sass/tree/variable_node.rb +10 -0
  58. data/lib/sass/tree/while_node.rb +11 -1
  59. data/lib/sass.rb +544 -534
  60. metadata +7 -6
  61. data/FAQ +0 -138
@@ -1,166 +1,139 @@
1
- if defined?(ActionView) and not defined?(Merb::Plugins)
2
- module ActionView
3
- class Base # :nodoc:
4
- def render_with_haml(*args, &block)
5
- options = args.first
6
-
7
- # If render :layout is used with a block,
8
- # it concats rather than returning a string
9
- # so we need it to keep thinking it's Haml
10
- # until it hits the sub-render
11
- if is_haml? && !(options.is_a?(Hash) && options[:layout] && block_given?)
12
- return non_haml { render_without_haml(*args, &block) }
13
- end
14
- render_without_haml(*args, &block)
1
+ module ActionView
2
+ class Base
3
+ def render_with_haml(*args, &block)
4
+ options = args.first
5
+
6
+ # If render :layout is used with a block,
7
+ # it concats rather than returning a string
8
+ # so we need it to keep thinking it's Haml
9
+ # until it hits the sub-render
10
+ if is_haml? && !(options.is_a?(Hash) && options[:layout] && block_given?)
11
+ return non_haml { render_without_haml(*args, &block) }
12
+ end
13
+ render_without_haml(*args, &block)
14
+ end
15
+ alias_method :render_without_haml, :render
16
+ alias_method :render, :render_with_haml
17
+
18
+ # Rails >2.1
19
+ if Haml::Util.has?(:instance_method, self, :output_buffer)
20
+ def output_buffer_with_haml
21
+ return haml_buffer.buffer if is_haml?
22
+ output_buffer_without_haml
15
23
  end
16
- alias_method :render_without_haml, :render
17
- alias_method :render, :render_with_haml
18
-
19
- # Rails >2.1
20
- if Haml::Util.has?(:instance_method, self, :output_buffer)
21
- def output_buffer_with_haml
22
- return haml_buffer.buffer if is_haml?
23
- output_buffer_without_haml
24
+ alias_method :output_buffer_without_haml, :output_buffer
25
+ alias_method :output_buffer, :output_buffer_with_haml
26
+
27
+ def set_output_buffer_with_haml(new)
28
+ if is_haml?
29
+ haml_buffer.buffer = new
30
+ else
31
+ set_output_buffer_without_haml new
24
32
  end
25
- alias_method :output_buffer_without_haml, :output_buffer
26
- alias_method :output_buffer, :output_buffer_with_haml
33
+ end
34
+ alias_method :set_output_buffer_without_haml, :output_buffer=
35
+ alias_method :output_buffer=, :set_output_buffer_with_haml
36
+ end
37
+ end
27
38
 
28
- def set_output_buffer_with_haml(new)
29
- if is_haml?
30
- haml_buffer.buffer = new
39
+ module Helpers
40
+ # In Rails <=2.1, we've got to override considerable capturing infrastructure.
41
+ # In Rails >2.1, we can make do with only overriding #capture
42
+ # (which no longer behaves differently in helper contexts).
43
+ unless Haml::Util.has?(:instance_method, ActionView::Base, :output_buffer)
44
+ module CaptureHelper
45
+ def capture_with_haml(*args, &block)
46
+ # Rails' #capture helper will just return the value of the block
47
+ # if it's not actually in the template context,
48
+ # as detected by the existance of an _erbout variable.
49
+ # We've got to do the same thing for compatibility.
50
+
51
+ if is_haml? && block_is_haml?(block)
52
+ capture_haml(*args, &block)
31
53
  else
32
- set_output_buffer_without_haml new
54
+ capture_without_haml(*args, &block)
33
55
  end
34
56
  end
35
- alias_method :set_output_buffer_without_haml, :output_buffer=
36
- alias_method :output_buffer=, :set_output_buffer_with_haml
37
- end
38
- end
57
+ alias_method :capture_without_haml, :capture
58
+ alias_method :capture, :capture_with_haml
39
59
 
40
- # This overrides various helpers in ActionView
41
- # to make them work more effectively with Haml.
42
- module Helpers
43
- # :stopdoc:
44
- # In Rails <=2.1, we've got to override considerable capturing infrastructure.
45
- # In Rails >2.1, we can make do with only overriding #capture
46
- # (which no longer behaves differently in helper contexts).
47
- unless Haml::Util.has?(:instance_method, ActionView::Base, :output_buffer)
48
- module CaptureHelper
49
- def capture_with_haml(*args, &block)
50
- # Rails' #capture helper will just return the value of the block
51
- # if it's not actually in the template context,
52
- # as detected by the existance of an _erbout variable.
53
- # We've got to do the same thing for compatibility.
54
-
55
- if is_haml? && block_is_haml?(block)
56
- capture_haml(*args, &block)
57
- else
58
- capture_without_haml(*args, &block)
59
- end
60
- end
61
- alias_method :capture_without_haml, :capture
62
- alias_method :capture, :capture_with_haml
63
-
64
- def capture_erb_with_buffer_with_haml(buffer, *args, &block)
65
- if is_haml?
66
- capture_haml(*args, &block)
67
- else
68
- capture_erb_with_buffer_without_haml(buffer, *args, &block)
69
- end
60
+ def capture_erb_with_buffer_with_haml(buffer, *args, &block)
61
+ if is_haml?
62
+ capture_haml(*args, &block)
63
+ else
64
+ capture_erb_with_buffer_without_haml(buffer, *args, &block)
70
65
  end
71
- alias_method :capture_erb_with_buffer_without_haml, :capture_erb_with_buffer
72
- alias_method :capture_erb_with_buffer, :capture_erb_with_buffer_with_haml
73
66
  end
67
+ alias_method :capture_erb_with_buffer_without_haml, :capture_erb_with_buffer
68
+ alias_method :capture_erb_with_buffer, :capture_erb_with_buffer_with_haml
69
+ end
74
70
 
75
- module TextHelper
76
- def concat_with_haml(string, binding = nil)
77
- if is_haml?
78
- haml_buffer.buffer.concat(string)
79
- else
80
- concat_without_haml(string, binding)
81
- end
71
+ module TextHelper
72
+ def concat_with_haml(string, binding = nil)
73
+ if is_haml?
74
+ haml_buffer.buffer.concat(string)
75
+ else
76
+ concat_without_haml(string, binding)
82
77
  end
83
- alias_method :concat_without_haml, :concat
84
- alias_method :concat, :concat_with_haml
85
78
  end
86
- else
87
- module CaptureHelper
88
- def capture_with_haml(*args, &block)
89
- if Haml::Helpers.block_is_haml?(block)
90
- capture_haml(*args, &block)
91
- else
92
- capture_without_haml(*args, &block)
93
- end
79
+ alias_method :concat_without_haml, :concat
80
+ alias_method :concat, :concat_with_haml
81
+ end
82
+ else
83
+ module CaptureHelper
84
+ def capture_with_haml(*args, &block)
85
+ if Haml::Helpers.block_is_haml?(block)
86
+ capture_haml(*args, &block)
87
+ else
88
+ capture_without_haml(*args, &block)
94
89
  end
95
- alias_method :capture_without_haml, :capture
96
- alias_method :capture, :capture_with_haml
97
90
  end
91
+ alias_method :capture_without_haml, :capture
92
+ alias_method :capture, :capture_with_haml
98
93
  end
94
+ end
99
95
 
100
- module TagHelper
101
- def content_tag_with_haml(name, *args, &block)
102
- return content_tag_without_haml(name, *args, &block) unless is_haml?
96
+ module TagHelper
97
+ def content_tag_with_haml(name, *args, &block)
98
+ return content_tag_without_haml(name, *args, &block) unless is_haml?
103
99
 
104
- preserve = haml_buffer.options[:preserve].include?(name.to_s)
100
+ preserve = haml_buffer.options[:preserve].include?(name.to_s)
105
101
 
106
- if block_given? && block_is_haml?(block) && preserve
107
- return content_tag_without_haml(name, *args) {preserve(&block)}
108
- end
109
-
110
- returning content_tag_without_haml(name, *args, &block) do |content|
111
- return Haml::Helpers.preserve(content) if preserve && content
112
- end
102
+ if block_given? && block_is_haml?(block) && preserve
103
+ return content_tag_without_haml(name, *args) {preserve(&block)}
113
104
  end
114
105
 
115
- alias_method :content_tag_without_haml, :content_tag
116
- alias_method :content_tag, :content_tag_with_haml
106
+ returning content_tag_without_haml(name, *args, &block) do |content|
107
+ return Haml::Helpers.preserve(content) if preserve && content
108
+ end
117
109
  end
118
110
 
119
- class InstanceTag
120
- # Includes TagHelper
111
+ alias_method :content_tag_without_haml, :content_tag
112
+ alias_method :content_tag, :content_tag_with_haml
113
+ end
121
114
 
122
- def haml_buffer
123
- @template_object.send :haml_buffer
124
- end
115
+ class InstanceTag
116
+ # Includes TagHelper
125
117
 
126
- def is_haml?
127
- @template_object.send :is_haml?
128
- end
129
-
130
- alias_method :content_tag_without_haml, :content_tag
131
- alias_method :content_tag, :content_tag_with_haml
118
+ def haml_buffer
119
+ @template_object.send :haml_buffer
132
120
  end
133
121
 
134
- module FormTagHelper
135
- def form_tag_with_haml(url_for_options = {}, options = {}, *parameters_for_url, &proc)
136
- if is_haml?
137
- if block_given?
138
- oldproc = proc
139
- proc = haml_bind_proc do |*args|
140
- concat "\n"
141
- tab_up
142
- oldproc.call(*args)
143
- tab_down
144
- concat haml_indent
145
- end
146
- concat haml_indent
147
- end
148
- res = form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc) + "\n"
149
- concat "\n" if block_given?
150
- res
151
- else
152
- form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc)
153
- end
154
- end
155
- alias_method :form_tag_without_haml, :form_tag
156
- alias_method :form_tag, :form_tag_with_haml
122
+ def is_haml?
123
+ @template_object.send :is_haml?
157
124
  end
158
125
 
159
- module FormHelper
160
- def form_for_with_haml(object_name, *args, &proc)
161
- if block_given? && is_haml?
126
+ alias_method :content_tag_without_haml, :content_tag
127
+ alias_method :content_tag, :content_tag_with_haml
128
+ end
129
+
130
+ module FormTagHelper
131
+ def form_tag_with_haml(url_for_options = {}, options = {}, *parameters_for_url, &proc)
132
+ if is_haml?
133
+ if block_given?
162
134
  oldproc = proc
163
135
  proc = haml_bind_proc do |*args|
136
+ concat "\n"
164
137
  tab_up
165
138
  oldproc.call(*args)
166
139
  tab_down
@@ -168,14 +141,34 @@ if defined?(ActionView) and not defined?(Merb::Plugins)
168
141
  end
169
142
  concat haml_indent
170
143
  end
171
- form_for_without_haml(object_name, *args, &proc)
172
- concat "\n" if block_given? && is_haml?
144
+ res = form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc) + "\n"
145
+ concat "\n" if block_given?
146
+ res
147
+ else
148
+ form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc)
173
149
  end
174
- alias_method :form_for_without_haml, :form_for
175
- alias_method :form_for, :form_for_with_haml
176
150
  end
177
- # :startdoc:
151
+ alias_method :form_tag_without_haml, :form_tag
152
+ alias_method :form_tag, :form_tag_with_haml
153
+ end
154
+
155
+ module FormHelper
156
+ def form_for_with_haml(object_name, *args, &proc)
157
+ if block_given? && is_haml?
158
+ oldproc = proc
159
+ proc = haml_bind_proc do |*args|
160
+ tab_up
161
+ oldproc.call(*args)
162
+ tab_down
163
+ concat haml_indent
164
+ end
165
+ concat haml_indent
166
+ end
167
+ form_for_without_haml(object_name, *args, &proc)
168
+ concat "\n" if block_given? && is_haml?
169
+ end
170
+ alias_method :form_for_without_haml, :form_for
171
+ alias_method :form_for, :form_for_with_haml
178
172
  end
179
173
  end
180
174
  end
181
-