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
data/lib/haml/helpers.rb CHANGED
@@ -1,24 +1,31 @@
1
- require 'haml/helpers/action_view_mods'
2
- require 'haml/helpers/action_view_extensions'
1
+ if defined?(ActionView)
2
+ require 'haml/helpers/action_view_mods'
3
+ require 'haml/helpers/action_view_extensions'
4
+ end
3
5
 
4
6
  module Haml
5
- # This module contains various helpful methods to make it easier to do
6
- # various tasks. Haml::Helpers is automatically included in the context
7
+ # This module contains various helpful methods to make it easier to do various tasks.
8
+ # {Haml::Helpers} is automatically included in the context
7
9
  # that a Haml template is parsed in, so all these methods are at your
8
10
  # disposal from within the template.
9
11
  module Helpers
10
- # An object that raises an error when #to_s is called.
12
+ # An object that raises an error when \{#to\_s} is called.
11
13
  # It's used to raise an error when the return value of a helper is used
12
14
  # when it shouldn't be.
13
15
  class ErrorReturn
16
+ # @param message [String] The error message to raise when \{#to\_s} is called
14
17
  def initialize(message)
15
18
  @message = message
16
19
  end
17
20
 
21
+ # Raises an error.
22
+ #
23
+ # @raise [Haml::Error] The error
18
24
  def to_s
19
25
  raise Haml::Error.new(@message)
20
26
  end
21
27
 
28
+ # @return [String] A human-readable string representation
22
29
  def inspect
23
30
  "Haml::Helpers::ErrorReturn(#{@message.inspect})"
24
31
  end
@@ -29,45 +36,41 @@ module Haml
29
36
  @@action_view_defined = defined?(ActionView)
30
37
  @@force_no_action_view = false
31
38
 
32
- # Returns whether or not ActionView is installed on the system.
39
+ # @return [Boolean] Whether or not ActionView is loaded
33
40
  def self.action_view?
34
41
  @@action_view_defined
35
42
  end
36
43
 
37
- # Note: this does *not* need to be called
38
- # when using Haml helpers normally
39
- # in Rails.
44
+ # Note: this does **not** need to be called when using Haml helpers
45
+ # normally in Rails.
40
46
  #
41
- # Initializes the current object
42
- # as though it were in the same context
43
- # as a normal ActionView rendering
44
- # using Haml.
47
+ # Initializes the current object as though it were in the same context
48
+ # as a normal ActionView instance using Haml.
45
49
  # This is useful if you want to use the helpers in a context
46
50
  # other than the normal setup with ActionView.
47
51
  # For example:
48
52
  #
49
- # context = Object.new
50
- # class << context
51
- # include Haml::Helpers
52
- # end
53
- # context.init_haml_helpers
54
- # context.haml_tag :p, "Stuff"
53
+ # context = Object.new
54
+ # class << context
55
+ # include Haml::Helpers
56
+ # end
57
+ # context.init_haml_helpers
58
+ # context.haml_tag :p, "Stuff"
55
59
  #
56
60
  def init_haml_helpers
57
61
  @haml_buffer = Haml::Buffer.new(@haml_buffer, Haml::Engine.new('').send(:options_for_buffer))
58
62
  nil
59
63
  end
60
64
 
61
- # call-seq:
62
- # non_haml { ... }
63
- #
64
65
  # Runs a block of code in a non-Haml context
65
- # (i.e. #is_haml? will return false).
66
+ # (i.e. \{#is\_haml?} will return false).
66
67
  #
67
68
  # This is mainly useful for rendering sub-templates such as partials in a non-Haml language,
68
69
  # particularly where helpers may behave differently when run from Haml.
69
70
  #
70
71
  # Note that this is automatically applied to Rails partials.
72
+ #
73
+ # @yield A block which won't register as Haml
71
74
  def non_haml
72
75
  was_active = @haml_buffer.active?
73
76
  @haml_buffer.active = false
@@ -76,14 +79,19 @@ module Haml
76
79
  @haml_buffer.active = was_active
77
80
  end
78
81
 
79
- # call-seq:
80
- # find_and_preserve(input, tags = haml_buffer.options[:preserve])
81
- # find_and_preserve(tags = haml_buffer.options[:preserve]) {...}
82
- #
83
- # Uses preserve to convert any newlines inside whitespace-sensitive tags
82
+ # Uses \{#preserve} to convert any newlines inside whitespace-sensitive tags
84
83
  # into the HTML entities for endlines.
85
- # +tags+ is an array of tags to preserve.
86
- # It defaults to the value of the <tt>:preserve</tt> option.
84
+ #
85
+ # @param tags [Array<String>] Tags that should have newlines escaped
86
+ #
87
+ # @overload find_and_preserve(input, tags = haml_buffer.options[:preserve])
88
+ # Escapes newlines within a string.
89
+ #
90
+ # @param input [String] The string within which to escape newlines
91
+ # @overload find_and_preserve(tags = haml_buffer.options[:preserve])
92
+ # Escapes newlines within a block of Haml code.
93
+ #
94
+ # @yield The block within which to escape newlines
87
95
  def find_and_preserve(input = nil, tags = haml_buffer.options[:preserve], &block)
88
96
  return find_and_preserve(capture_haml(&block), input || tags) if block
89
97
 
@@ -93,55 +101,62 @@ module Haml
93
101
  end
94
102
  end
95
103
 
96
- # call-seq:
97
- # preserve(input)
98
- # preserve {...}
99
- #
100
- # Takes any string, finds all the endlines and converts them to
101
- # HTML entities for endlines so they'll render correctly in
104
+ # Takes any string, finds all the newlines, and converts them to
105
+ # HTML entities so they'll render correctly in
102
106
  # whitespace-sensitive tags without screwing up the indentation.
107
+ #
108
+ # @overload perserve(input)
109
+ # Escapes newlines within a string.
110
+ #
111
+ # @param input [String] The string within which to escape all newlines
112
+ # @overload perserve
113
+ # Escapes newlines within a block of Haml code.
114
+ #
115
+ # @yield The block within which to escape newlines
103
116
  def preserve(input = '', &block)
104
117
  return preserve(capture_haml(&block)) if block
105
118
 
106
119
  input.chomp("\n").gsub(/\n/, '&#x000A;').gsub(/\r/, '')
107
120
  end
108
-
109
121
  alias_method :flatten, :preserve
110
122
 
111
- # Takes an Enumerable object and a block
112
- # and iterates over the object,
123
+ # Takes an `Enumerable` object and a block
124
+ # and iterates over the enum,
113
125
  # yielding each element to a Haml block
114
- # and putting the result into <tt><li></tt> elements.
126
+ # and putting the result into `<li>` elements.
115
127
  # This creates a list of the results of the block.
116
128
  # For example:
117
129
  #
118
- # = list_of([['hello'], ['yall']]) do |i|
119
- # = i[0]
130
+ # = list_of([['hello'], ['yall']]) do |i|
131
+ # = i[0]
120
132
  #
121
133
  # Produces:
122
134
  #
123
- # <li>hello</li>
124
- # <li>yall</li>
135
+ # <li>hello</li>
136
+ # <li>yall</li>
125
137
  #
126
138
  # And
127
139
  #
128
- # = list_of({:title => 'All the stuff', :description => 'A book about all the stuff.'}) do |key, val|
129
- # %h3= key.humanize
130
- # %p= val
140
+ # = list_of({:title => 'All the stuff', :description => 'A book about all the stuff.'}) do |key, val|
141
+ # %h3= key.humanize
142
+ # %p= val
131
143
  #
132
144
  # Produces:
133
145
  #
134
- # <li>
135
- # <h3>Title</h3>
136
- # <p>All the stuff</p>
137
- # </li>
138
- # <li>
139
- # <h3>Description</h3>
140
- # <p>A book about all the stuff.</p>
141
- # </li>
142
- #
143
- def list_of(array, &block) # :yields: item
144
- to_return = array.collect do |i|
146
+ # <li>
147
+ # <h3>Title</h3>
148
+ # <p>All the stuff</p>
149
+ # </li>
150
+ # <li>
151
+ # <h3>Description</h3>
152
+ # <p>A book about all the stuff.</p>
153
+ # </li>
154
+ #
155
+ # @param enum [Enumerable] The list of objects to iterate over
156
+ # @yield [item] A block which contains Haml code that goes within list items
157
+ # @yieldparam item An element of `enum`
158
+ def list_of(enum, &block)
159
+ to_return = enum.collect do |i|
145
160
  result = capture_haml(i, &block)
146
161
 
147
162
  if result.count("\n") > 1
@@ -156,18 +171,18 @@ module Haml
156
171
  to_return.join("\n")
157
172
  end
158
173
 
159
- # Returns a hash containing default assignments for the xmlns and xml:lang
160
- # attributes of the <tt>html</tt> HTML element.
161
- # It also takes an optional argument for the value of xml:lang and lang,
162
- # which defaults to 'en-US'.
174
+ # Returns a hash containing default assignments for the `xmlns`, `lang`, and `xml:lang`
175
+ # attributes of the `html` HTML element.
163
176
  # For example,
164
177
  #
165
- # %html{html_attrs}
178
+ # %html{html_attrs}
166
179
  #
167
180
  # becomes
168
181
  #
169
- # <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en-US' lang='en-US'>
182
+ # <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en-US' lang='en-US'>
170
183
  #
184
+ # @param lang [String] The value of `xml:lang` and `lang`
185
+ # @return [Hash<#to_s, String>] The attribute hash
171
186
  def html_attrs(lang = 'en-US')
172
187
  {:xmlns => "http://www.w3.org/1999/xhtml", 'xml:lang' => lang, :lang => lang}
173
188
  end
@@ -176,18 +191,20 @@ module Haml
176
191
  # to the lines of the template.
177
192
  # For example:
178
193
  #
179
- # %h1 foo
180
- # - tab_up
181
- # %p bar
182
- # - tab_down
183
- # %strong baz
194
+ # %h1 foo
195
+ # - tab_up
196
+ # %p bar
197
+ # - tab_down
198
+ # %strong baz
184
199
  #
185
200
  # Produces:
186
201
  #
187
- # <h1>foo</h1>
188
- # <p>bar</p>
189
- # <strong>baz</strong>
202
+ # <h1>foo</h1>
203
+ # <p>bar</p>
204
+ # <strong>baz</strong>
190
205
  #
206
+ # @param i [Fixnum] The number of tabs by which to increase the indentation
207
+ # @see #tab_down
191
208
  def tab_up(i = 1)
192
209
  haml_buffer.tabulation += i
193
210
  end
@@ -195,81 +212,91 @@ module Haml
195
212
  # Decrements the number of tabs the buffer automatically adds
196
213
  # to the lines of the template.
197
214
  #
198
- # See also tab_up.
215
+ # @param i [Fixnum] The number of tabs by which to decrease the indentation
216
+ # @see #tab_up
199
217
  def tab_down(i = 1)
200
218
  haml_buffer.tabulation -= i
201
219
  end
202
220
 
203
- # Surrounds the given block of Haml code with the given characters,
221
+ # Surrounds a block of Haml code with strings,
204
222
  # with no whitespace in between.
205
223
  # For example:
206
224
  #
207
- # = surround '(', ')' do
208
- # %a{:href => "food"} chicken
225
+ # = surround '(', ')' do
226
+ # %a{:href => "food"} chicken
209
227
  #
210
228
  # Produces:
211
229
  #
212
- # (<a href='food'>chicken</a>)
230
+ # (<a href='food'>chicken</a>)
213
231
  #
214
232
  # and
215
233
  #
216
- # = surround '*' do
217
- # %strong angry
234
+ # = surround '*' do
235
+ # %strong angry
218
236
  #
219
237
  # Produces:
220
238
  #
221
- # *<strong>angry</strong>*
239
+ # *<strong>angry</strong>*
222
240
  #
223
- def surround(front, back = nil, &block)
224
- back ||= front
241
+ # @param front [String] The string to add before the Haml
242
+ # @param back [String] The string to add after the Haml
243
+ # @yield A block of Haml to surround
244
+ def surround(front, back = front, &block)
225
245
  output = capture_haml(&block)
226
246
 
227
247
  "#{front}#{output.chomp}#{back}\n"
228
248
  end
229
249
 
230
- # Prepends the given character to the beginning of the Haml block,
250
+ # Prepends a string to the beginning of a Haml block,
231
251
  # with no whitespace between.
232
252
  # For example:
233
253
  #
234
- # = precede '*' do
235
- # %span.small Not really
254
+ # = precede '*' do
255
+ # %span.small Not really
236
256
  #
237
257
  # Produces:
238
258
  #
239
- # *<span class='small'>Not really</span>
259
+ # *<span class='small'>Not really</span>
240
260
  #
241
- def precede(char, &block)
242
- "#{char}#{capture_haml(&block).chomp}\n"
261
+ # @param str [String] The string to add before the Haml
262
+ # @yield A block of Haml to prepend to
263
+ def precede(str, &block)
264
+ "#{str}#{capture_haml(&block).chomp}\n"
243
265
  end
244
266
 
245
- # Appends the given character to the end of the Haml block,
267
+ # Appends a string to the end of a Haml block,
246
268
  # with no whitespace between.
247
269
  # For example:
248
270
  #
249
- # click
250
- # = succeed '.' do
251
- # %a{:href=>"thing"} here
271
+ # click
272
+ # = succeed '.' do
273
+ # %a{:href=>"thing"} here
252
274
  #
253
275
  # Produces:
254
276
  #
255
- # click
256
- # <a href='thing'>here</a>.
277
+ # click
278
+ # <a href='thing'>here</a>.
257
279
  #
258
- def succeed(char, &block)
259
- "#{capture_haml(&block).chomp}#{char}\n"
280
+ # @param str [String] The string to add after the Haml
281
+ # @yield A block of Haml to append to
282
+ def succeed(str, &block)
283
+ "#{capture_haml(&block).chomp}#{str}\n"
260
284
  end
261
285
 
262
- # Captures the result of the given block of Haml code,
286
+ # Captures the result of a block of Haml code,
263
287
  # gets rid of the excess indentation,
264
288
  # and returns it as a string.
265
289
  # For example, after the following,
266
290
  #
267
- # .foo
268
- # - foo = capture_haml(13) do |a|
269
- # %p= a
291
+ # .foo
292
+ # - foo = capture_haml(13) do |a|
293
+ # %p= a
270
294
  #
271
- # the local variable <tt>foo</tt> would be assigned to "<p>13</p>\n".
295
+ # the local variable `foo` would be assigned to `"<p>13</p>\n"`.
272
296
  #
297
+ # @param args [Array] Arguments to pass into the block
298
+ # @yield [args] A block of Haml code that will be converted to a string
299
+ # @yieldparam args [Array] `args`
273
300
  def capture_haml(*args, &block)
274
301
  buffer = eval('_hamlout', block.binding) rescue haml_buffer
275
302
  with_haml_buffer(buffer) do
@@ -295,7 +322,9 @@ module Haml
295
322
  haml_buffer.capture_position = nil
296
323
  end
297
324
 
298
- def puts(*args) # :nodoc:
325
+ # @deprecated This will be removed in version 2.4.
326
+ # @see \{#haml\_concat}
327
+ def puts(*args)
299
328
  warn <<END
300
329
  DEPRECATION WARNING:
301
330
  The Haml #puts helper is deprecated and will be removed in version 2.4.
@@ -304,67 +333,76 @@ END
304
333
  haml_concat(*args)
305
334
  end
306
335
 
307
- # Outputs text directly to the Haml buffer, with the proper tabulation
336
+ # Outputs text directly to the Haml buffer, with the proper indentation.
337
+ #
338
+ # @param text [#to_s] The text to output
308
339
  def haml_concat(text = "")
309
340
  haml_buffer.buffer << haml_indent << text.to_s << "\n"
310
341
  nil
311
342
  end
312
343
 
313
- # Returns the string that should be used to indent the current line
344
+ # @return [String] The indentation string for the current line
314
345
  def haml_indent
315
346
  ' ' * haml_buffer.tabulation
316
347
  end
317
348
 
318
- #
319
- # call-seq:
320
- # haml_tag(name, *flags, attributes = {}) {...}
321
- # haml_tag(name, text, *flags, attributes = {}) {...}
322
- #
323
349
  # Creates an HTML tag with the given name and optionally text and attributes.
324
- # Can take a block that will be executed
325
- # between when the opening and closing tags are output.
326
- # If the block is a Haml block or outputs text using haml_concat,
350
+ # Can take a block that will run between the opening and closing tags.
351
+ # If the block is a Haml block or outputs text using \{#haml\_concat},
327
352
  # the text will be properly indented.
328
353
  #
329
- # <tt>flags</tt> is a list of symbol flags
354
+ # `flags` is a list of symbol flags
330
355
  # like those that can be put at the end of a Haml tag
331
- # (<tt>:/</tt>, <tt>:<</tt>, and <tt>:></tt>).
332
- # Currently, only <tt>:/</tt> and <tt>:<</tt> are supported.
356
+ # (`:/`, `:<`, and `:>`).
357
+ # Currently, only `:/` and `:<` are supported.
358
+ #
359
+ # `haml_tag` outputs directly to the buffer;
360
+ # its return value should not be used.
361
+ # If you need to get the results as a string,
362
+ # use \{#capture\_haml\}.
333
363
  #
334
364
  # For example,
335
365
  #
336
- # haml_tag :table do
337
- # haml_tag :tr do
338
- # haml_tag :td, {:class => 'cell'} do
339
- # haml_tag :strong, "strong!"
340
- # haml_concat "data"
341
- # end
342
- # haml_tag :td do
343
- # haml_concat "more_data"
366
+ # haml_tag :table do
367
+ # haml_tag :tr do
368
+ # haml_tag :td, {:class => 'cell'} do
369
+ # haml_tag :strong, "strong!"
370
+ # haml_concat "data"
371
+ # end
372
+ # haml_tag :td do
373
+ # haml_concat "more_data"
374
+ # end
344
375
  # end
345
376
  # end
346
- # end
347
377
  #
348
378
  # outputs
349
379
  #
350
- # <table>
351
- # <tr>
352
- # <td class='cell'>
353
- # <strong>
354
- # strong!
355
- # </strong>
356
- # data
357
- # </td>
358
- # <td>
359
- # more_data
360
- # </td>
361
- # </tr>
362
- # </table>
363
- #
380
+ # <table>
381
+ # <tr>
382
+ # <td class='cell'>
383
+ # <strong>
384
+ # strong!
385
+ # </strong>
386
+ # data
387
+ # </td>
388
+ # <td>
389
+ # more_data
390
+ # </td>
391
+ # </tr>
392
+ # </table>
393
+ #
394
+ # @param name [#to_s] The name of the tag
395
+ # @param flags [Array<Symbol>] Haml end-of-tag flags
396
+ #
397
+ # @overload haml_tag(name, *flags, attributes = {})
398
+ # @yield The block of Haml code within the tag
399
+ # @overload haml_tag(name, text, *flags, attributes = {})
400
+ # @param text [#to_s] The text within the tag
364
401
  def haml_tag(name, *rest, &block)
365
402
  ret = ErrorReturn.new(<<MESSAGE)
366
403
  haml_tag outputs directly to the Haml template.
367
- Disregard its return value and use the - operator.
404
+ Disregard its return value and use the - operator,
405
+ or use capture_haml to get the value as a String.
368
406
  MESSAGE
369
407
 
370
408
  name = name.to_s
@@ -414,28 +452,39 @@ MESSAGE
414
452
  # Characters that need to be escaped to HTML entities from user input
415
453
  HTML_ESCAPE = { '&'=>'&amp;', '<'=>'&lt;', '>'=>'&gt;', '"'=>'&quot;', "'"=>'&#039;', }
416
454
 
417
- # Returns a copy of <tt>text</tt> with ampersands, angle brackets and quotes
455
+ # Returns a copy of `text` with ampersands, angle brackets and quotes
418
456
  # escaped into HTML entities.
457
+ #
458
+ # @param text [String] The string to sanitize
459
+ # @return [String] The sanitized string
419
460
  def html_escape(text)
420
461
  text.to_s.gsub(/[\"><&]/) { |s| HTML_ESCAPE[s] }
421
462
  end
422
463
 
423
- # Escapes HTML entities in <tt>text</tt>, but without escaping an ampersand
464
+ # Escapes HTML entities in `text`, but without escaping an ampersand
424
465
  # that is already part of an escaped entity.
466
+ #
467
+ # @param text [String] The string to sanitize
468
+ # @return [String] The sanitized string
425
469
  def escape_once(text)
426
470
  text.to_s.gsub(/[\"><]|&(?!([a-zA-Z]+|(#\d+));)/) { |s| HTML_ESCAPE[s] }
427
471
  end
428
472
 
429
473
  # Returns whether or not the current template is a Haml template.
430
474
  #
431
- # This function, unlike other Haml::Helpers functions,
432
- # also works in other ActionView templates,
475
+ # This function, unlike other {Haml::Helpers} functions,
476
+ # also works in other `ActionView` templates,
433
477
  # where it will always return false.
478
+ #
479
+ # @return [Boolean] Whether or not the current template is a Haml template
434
480
  def is_haml?
435
481
  !@haml_buffer.nil? && @haml_buffer.active?
436
482
  end
437
483
 
438
- # Returns whether or not +block+ is defined directly in a Haml template.
484
+ # Returns whether or not `block` is defined directly in a Haml template.
485
+ #
486
+ # @param block [Proc] A Ruby block
487
+ # @return [Boolean] Whether or not `block` is defined directly in a Haml template
439
488
  def block_is_haml?(block)
440
489
  eval('_hamlout', block.binding)
441
490
  true
@@ -445,10 +494,10 @@ MESSAGE
445
494
 
446
495
  private
447
496
 
448
- # call-seq:
449
- # with_haml_buffer(buffer) {...}
497
+ # Runs a block of code with the given buffer as the currently active buffer.
450
498
  #
451
- # Runs the block with the given buffer as the currently active buffer.
499
+ # @param buffer [Haml::Buffer] The Haml buffer to use temporarily
500
+ # @yield A block in which the given buffer should be used
452
501
  def with_haml_buffer(buffer)
453
502
  @haml_buffer, old_buffer = buffer, @haml_buffer
454
503
  old_buffer.active, was_active = false, old_buffer.active? if old_buffer
@@ -460,13 +509,18 @@ MESSAGE
460
509
  @haml_buffer = old_buffer
461
510
  end
462
511
 
463
- # Gets a reference to the current Haml::Buffer object.
512
+ # The current {Haml::Buffer} object.
513
+ #
514
+ # @return [Haml::Buffer]
464
515
  def haml_buffer
465
516
  @haml_buffer
466
517
  end
467
518
 
468
- # Gives a proc the same local "_hamlout" and "_erbout" variables
519
+ # Gives a proc the same local `_hamlout` and `_erbout` variables
469
520
  # that the current template has.
521
+ #
522
+ # @param proc [#call] The proc to bind
523
+ # @return [Proc] A new proc with the new variables bound
470
524
  def haml_bind_proc(&proc)
471
525
  _hamlout = haml_buffer
472
526
  _erbout = _hamlout.buffer
@@ -478,12 +532,12 @@ MESSAGE
478
532
  end
479
533
 
480
534
  class Object
481
- # Haml overrides various ActionView helpers,
482
- # which call an #is_haml? method
535
+ # Haml overrides various `ActionView` helpers,
536
+ # which call an \{#is\_haml?} method
483
537
  # to determine whether or not the current context object
484
538
  # is a proper Haml context.
485
- # Because ActionView helpers may be included in non-ActionView::Base classes,
486
- # it's a good idea to define is_haml? for all objects.
539
+ # Because `ActionView` helpers may be included in non-`ActionView::Base` classes,
540
+ # it's a good idea to define \{#is\_haml?} for all objects.
487
541
  def is_haml?
488
542
  false
489
543
  end