haml-edge 2.1.21 → 2.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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.rb CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
3
3
 
4
4
  require 'haml/version'
5
5
 
6
- # = Haml (XHTML Abstraction Markup Language)
6
+ # # Haml (XHTML Abstraction Markup Language)
7
7
  #
8
8
  # Haml is a markup language
9
9
  # that's used to cleanly and simply describe the XHTML of any web document,
@@ -14,7 +14,7 @@ require 'haml/version'
14
14
  # because it is actually an abstract description of the XHTML,
15
15
  # with some code to generate dynamic content.
16
16
  #
17
- # == Features
17
+ # ## Features
18
18
  #
19
19
  # * Whitespace active
20
20
  # * Well-formatted markup
@@ -23,7 +23,7 @@ require 'haml/version'
23
23
  # * Integrates Ruby code
24
24
  # * Implements Rails templates with the .haml extension
25
25
  #
26
- # == Using Haml
26
+ # ## Using Haml
27
27
  #
28
28
  # Haml can be used in three ways:
29
29
  # as a plugin for Ruby on Rails,
@@ -31,98 +31,98 @@ require 'haml/version'
31
31
  # and as a command-line tool.
32
32
  # The first step for all of these is to install the Haml gem:
33
33
  #
34
- # gem install haml
34
+ # gem install haml
35
35
  #
36
36
  # To enable it as a Rails plugin,
37
37
  # then run
38
38
  #
39
- # haml --rails path/to/rails/app
39
+ # haml --rails path/to/rails/app
40
40
  #
41
- # Once it's installed, all view files with the ".html.haml" extension
41
+ # Once it's installed, all view files with the `".html.haml"` extension
42
42
  # will be compiled using Haml.
43
43
  #
44
44
  # To run Haml from the command line, just use
45
45
  #
46
- # haml input.haml output.html
46
+ # haml input.haml output.html
47
47
  #
48
- # Use <tt>haml --help</tt> for full documentation.
48
+ # Use `haml --help` for full documentation.
49
49
  #
50
50
  # You can access instance variables in Haml templates
51
- # the same way you do in ERb templates.
51
+ # the same way you do in ERB templates.
52
52
  # Helper methods are also available in Haml templates.
53
53
  # For example (this example uses Rails, but the principle for Merb is the same):
54
54
  #
55
- # # file: app/controllers/movies_controller.rb
55
+ # # file: app/controllers/movies_controller.rb
56
56
  #
57
- # class MoviesController < ApplicationController
58
- # def index
59
- # @title = "Teen Wolf"
57
+ # class MoviesController < ApplicationController
58
+ # def index
59
+ # @title = "Teen Wolf"
60
+ # end
60
61
  # end
61
- # end
62
62
  #
63
- # -# file: app/views/movies/index.haml
63
+ # -# file: app/views/movies/index.haml
64
64
  #
65
- # #content
66
- # .title
67
- # %h1= @title
68
- # = link_to 'Home', home_url
65
+ # #content
66
+ # .title
67
+ # %h1= @title
68
+ # = link_to 'Home', home_url
69
69
  #
70
70
  # may be compiled to:
71
71
  #
72
- # <div id='content'>
73
- # <div class='title'>
74
- # <h1>Teen Wolf</h1>
75
- # <a href='/'>Home</a>
72
+ # <div id='content'>
73
+ # <div class='title'>
74
+ # <h1>Teen Wolf</h1>
75
+ # <a href='/'>Home</a>
76
+ # </div>
76
77
  # </div>
77
- # </div>
78
78
  #
79
- # === Ruby Module
79
+ # ### Ruby Module
80
80
  #
81
81
  # Haml can also be used completely separately from Rails and ActionView.
82
82
  # To do this, install the gem with RubyGems:
83
83
  #
84
- # gem install haml
84
+ # gem install haml
85
85
  #
86
86
  # You can then use it by including the "haml" gem in Ruby code,
87
- # and using Haml::Engine like so:
87
+ # and using {Haml::Engine} like so:
88
88
  #
89
- # engine = Haml::Engine.new("%p Haml code!")
90
- # engine.render #=> "<p>Haml code!</p>\n"
89
+ # engine = Haml::Engine.new("%p Haml code!")
90
+ # engine.render #=> "<p>Haml code!</p>\n"
91
91
  #
92
- # == Characters with meaning to Haml
92
+ # ## Characters with meaning to Haml
93
93
  #
94
94
  # Various characters, when placed at a certain point in a line,
95
95
  # instruct Haml to render different types of things.
96
96
  #
97
- # === XHTML Tags
97
+ # ### XHTML Tags
98
98
  #
99
99
  # These characters render XHTML tags.
100
100
  #
101
- # ==== %
101
+ # #### %
102
102
  #
103
103
  # The percent character is placed at the beginning of a line.
104
104
  # It's followed immediately by the name of an element,
105
105
  # then optionally by modifiers (see below), a space,
106
106
  # and text to be rendered inside the element.
107
- # It creates an element in the form of <tt><element></element></tt>.
107
+ # It creates an element in the form of `<element></element>`.
108
108
  # For example:
109
109
  #
110
- # %one
111
- # %two
112
- # %three Hey there
110
+ # %one
111
+ # %two
112
+ # %three Hey there
113
113
  #
114
114
  # is compiled to:
115
115
  #
116
- # <one>
117
- # <two>
118
- # <three>Hey there</three>
119
- # </two>
120
- # </one>
116
+ # <one>
117
+ # <two>
118
+ # <three>Hey there</three>
119
+ # </two>
120
+ # </one>
121
121
  #
122
122
  # Any string is a valid element name;
123
123
  # Haml will automatically generate opening and closing tags for any element.
124
124
  #
125
- # ==== {}
125
+ # #### {}
126
126
  #
127
127
  # Brackets represent a Ruby hash
128
128
  # that is used for specifying the attributes of an element.
@@ -133,42 +133,42 @@ require 'haml/version'
133
133
  # The hash is placed after the tag is defined.
134
134
  # For example:
135
135
  #
136
- # %html{:xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "en", :lang => "en"}
136
+ # %html{:xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "en", :lang => "en"}
137
137
  #
138
138
  # is compiled to:
139
139
  #
140
- # <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'></html>
140
+ # <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'></html>
141
141
  #
142
142
  # Attribute hashes can also be stretched out over multiple lines
143
143
  # to accomidate many attributes.
144
144
  # However, newlines may only be placed immediately after commas.
145
145
  # For example:
146
146
  #
147
- # %script{:type => "text/javascript",
148
- # :src => "javascripts/script_#{2 + 7}"}
147
+ # %script{:type => "text/javascript",
148
+ # :src => "javascripts/script_#{2 + 7}"}
149
149
  #
150
150
  # is compiled to:
151
151
  #
152
- # <script src='javascripts/script_9' type='text/javascript'></script>
152
+ # <script src='javascripts/script_9' type='text/javascript'></script>
153
153
  #
154
- # ===== Attribute Methods
154
+ # ##### Attribute Methods
155
155
  #
156
156
  # A Ruby method call that returns a hash
157
157
  # can be substituted for the hash contents.
158
- # For example, Haml::Helpers defines the following method:
158
+ # For example, {Haml::Helpers} defines the following method:
159
159
  #
160
- # def html_attrs(lang = 'en-US')
161
- # {:xmlns => "http://www.w3.org/1999/xhtml", 'xml:lang' => lang, :lang => lang}
162
- # end
160
+ # def html_attrs(lang = 'en-US')
161
+ # {:xmlns => "http://www.w3.org/1999/xhtml", 'xml:lang' => lang, :lang => lang}
162
+ # end
163
163
  #
164
164
  # This can then be used in Haml, like so:
165
165
  #
166
- # %html{html_attrs('fr-fr')}
166
+ # %html{html_attrs('fr-fr')}
167
167
  #
168
168
  # This is compiled to:
169
169
  #
170
- # <html lang='fr-fr' xml:lang='fr-fr' xmlns='http://www.w3.org/1999/xhtml'>
171
- # </html>
170
+ # <html lang='fr-fr' xml:lang='fr-fr' xmlns='http://www.w3.org/1999/xhtml'>
171
+ # </html>
172
172
  #
173
173
  # You can use as many such attribute methods as you want
174
174
  # by separating them with commas,
@@ -176,151 +176,149 @@ require 'haml/version'
176
176
  # All the hashes will me merged together, from left to right.
177
177
  # For example, if you defined
178
178
  #
179
- # def hash1
180
- # {:bread => 'white', :filling => 'peanut butter and jelly'}
181
- # end
179
+ # def hash1
180
+ # {:bread => 'white', :filling => 'peanut butter and jelly'}
181
+ # end
182
182
  #
183
- # def hash2
184
- # {:bread => 'whole wheat'}
185
- # end
183
+ # def hash2
184
+ # {:bread => 'whole wheat'}
185
+ # end
186
186
  #
187
187
  # then
188
188
  #
189
- # %sandwich{hash1, hash2, :delicious => true}/
189
+ # %sandwich{hash1, hash2, :delicious => true}/
190
190
  #
191
191
  # would compile to:
192
192
  #
193
- # <sandwich bread='whole wheat' delicious='true' filling='peanut butter and jelly' />
193
+ # <sandwich bread='whole wheat' delicious='true' filling='peanut butter and jelly' />
194
194
  #
195
195
  # Note that the Haml attributes list has the same syntax as a Ruby method call.
196
196
  # This means that any attribute methods must come before the hash literal.
197
197
  #
198
- # ===== Boolean Attributes
198
+ # ##### Boolean Attributes
199
199
  #
200
- # Some attributes, such as "checked" for <tt>input</tt> tags or "selected" for <tt>option</tt> tags,
200
+ # Some attributes, such as "checked" for `input` tags or "selected" for `option` tags,
201
201
  # are "boolean" in the sense that their values don't matter -
202
202
  # it only matters whether or not they're present.
203
203
  # In HTML (but not XHTML), these attributes can be written as
204
204
  #
205
- # <input selected>
205
+ # <input selected>
206
206
  #
207
207
  # To do this in Haml, just assign a Ruby true value to the attribute:
208
208
  #
209
- # %input{:selected => true}
209
+ # %input{:selected => true}
210
210
  #
211
211
  # In XHTML, the only valid value for these attributes is the name of the attribute.
212
212
  # Thus this will render in XHTML as
213
213
  #
214
- # <input selected='selected'>
214
+ # <input selected='selected'>
215
215
  #
216
216
  # To set these attributes to false, simply assign them to a Ruby false value.
217
217
  # In both XHTML and HTML
218
218
  #
219
- # %input{:selected => false}
219
+ # %input{:selected => false}
220
220
  #
221
221
  # will just render as
222
222
  #
223
- # <input>
223
+ # <input>
224
224
  #
225
- # ==== . and #
225
+ # #### . and `#`
226
226
  #
227
227
  # The period and pound sign are borrowed from CSS.
228
- # They are used as shortcuts to specify the <tt>class</tt>
229
- # and <tt>id</tt> attributes of an element, respectively.
228
+ # They are used as shortcuts to specify the `class`
229
+ # and `id` attributes of an element, respectively.
230
230
  # Multiple class names can be specified in a similar way to CSS,
231
231
  # by chaining the class names together with periods.
232
232
  # They are placed immediately after the tag and before an attributes hash.
233
233
  # For example:
234
234
  #
235
- # %div#things
236
- # %span#rice Chicken Fried
237
- # %p.beans{ :food => 'true' } The magical fruit
238
- # %h1.class.otherclass#id La La La
235
+ # %div#things
236
+ # %span#rice Chicken Fried
237
+ # %p.beans{ :food => 'true' } The magical fruit
238
+ # %h1.class.otherclass#id La La La
239
239
  #
240
240
  # is compiled to:
241
241
  #
242
- # <div id='things'>
243
- # <span id='rice'>Chicken Fried</span>
244
- # <p class='beans' food='true'>The magical fruit</p>
245
- # <h1 class='class otherclass' id='id'>La La La</h1>
246
- # </div>
242
+ # <div id='things'>
243
+ # <span id='rice'>Chicken Fried</span>
244
+ # <p class='beans' food='true'>The magical fruit</p>
245
+ # <h1 class='class otherclass' id='id'>La La La</h1>
246
+ # </div>
247
247
  #
248
248
  # And,
249
249
  #
250
- # #content
251
- # .articles
252
- # .article.title
253
- # Doogie Howser Comes Out
254
- # .article.date
255
- # 2006-11-05
256
- # .article.entry
257
- # Neil Patrick Harris would like to dispel any rumors that he is straight
250
+ # #content
251
+ # .articles
252
+ # .article.title Doogie Howser Comes Out
253
+ # .article.date 2006-11-05
254
+ # .article.entry
255
+ # Neil Patrick Harris would like to dispel any rumors that he is straight
258
256
  #
259
257
  # is compiled to:
260
258
  #
261
- # <div id='content'>
262
- # <div class='articles'>
263
- # <div class='article title'>Doogie Howser Comes Out</div>
264
- # <div class='article date'>2006-11-05</div>
265
- # <div class='article entry'>
266
- # Neil Patrick Harris would like to dispel any rumors that he is straight
259
+ # <div id='content'>
260
+ # <div class='articles'>
261
+ # <div class='article title'>Doogie Howser Comes Out</div>
262
+ # <div class='article date'>2006-11-05</div>
263
+ # <div class='article entry'>
264
+ # Neil Patrick Harris would like to dispel any rumors that he is straight
265
+ # </div>
267
266
  # </div>
268
267
  # </div>
269
- # </div>
270
268
  #
271
- # ==== Implicit Div Elements
269
+ # #### Implicit Div Elements
272
270
  #
273
271
  # Because the div element is used so often, it is the default element.
274
- # If you only define a class and/or id using the <tt>.</tt> or <tt>#</tt> syntax,
272
+ # If you only define a class and/or id using the `.` or `#` syntax,
275
273
  # a div element is automatically used.
276
274
  # For example:
277
275
  #
278
- # #collection
279
- # .item
280
- # .description What a cool item!
276
+ # #collection
277
+ # .item
278
+ # .description What a cool item!
281
279
  #
282
280
  # is the same as:
283
281
  #
284
- # %div{:id => collection}
285
- # %div{:class => 'item'}
286
- # %div{:class => 'description'} What a cool item!
282
+ # %div{:id => collection}
283
+ # %div{:class => 'item'}
284
+ # %div{:class => 'description'} What a cool item!
287
285
  #
288
286
  # and is compiled to:
289
287
  #
290
- # <div id='collection'>
291
- # <div class='item'>
292
- # <div class='description'>What a cool item!</div>
288
+ # <div id='collection'>
289
+ # <div class='item'>
290
+ # <div class='description'>What a cool item!</div>
291
+ # </div>
293
292
  # </div>
294
- # </div>
295
293
  #
296
- # ==== /
294
+ # #### /
297
295
  #
298
296
  # The forward slash character, when placed at the end of a tag definition,
299
297
  # causes the tag to be self-closed.
300
298
  # For example:
301
299
  #
302
- # %br/
303
- # %meta{'http-equiv' => 'Content-Type', :content => 'text/html'}/
300
+ # %br/
301
+ # %meta{'http-equiv' => 'Content-Type', :content => 'text/html'}/
304
302
  #
305
303
  # is compiled to:
306
304
  #
307
- # <br />
308
- # <meta http-equiv='Content-Type' content='text/html' />
305
+ # <br />
306
+ # <meta http-equiv='Content-Type' content='text/html' />
309
307
  #
310
308
  # Some tags are automatically closed, as long as they have no content.
311
- # +meta+, +img+, +link+, +script+, +br+, and +hr+ tags are closed by default.
312
- # This list can be customized by setting the <tt>:autoclose</tt> option (see below).
309
+ # `meta`, `img`, `link`, `script`, `br`, and `hr` tags are closed by default.
310
+ # This list can be customized by setting the [`:autoclose`](#autoclose-option) option (see below).
313
311
  # For example:
314
312
  #
315
- # %br
316
- # %meta{'http-equiv' => 'Content-Type', :content => 'text/html'}
313
+ # %br
314
+ # %meta{'http-equiv' => 'Content-Type', :content => 'text/html'}
317
315
  #
318
316
  # is also compiled to:
319
317
  #
320
- # <br />
321
- # <meta http-equiv='Content-Type' content='text/html' />
318
+ # <br />
319
+ # <meta http-equiv='Content-Type' content='text/html' />
322
320
  #
323
- # ==== []
321
+ # #### \[]
324
322
  #
325
323
  # Square brackets follow a tag definition and contain a Ruby object
326
324
  # that is used to set the class and id of that tag.
@@ -333,338 +331,340 @@ require 'haml/version'
333
331
  # both the id and class attributes.
334
332
  # For example:
335
333
  #
336
- # # file: app/controllers/users_controller.rb
334
+ # # file: app/controllers/users_controller.rb
337
335
  #
338
- # def show
339
- # @user = CrazyUser.find(15)
340
- # end
336
+ # def show
337
+ # @user = CrazyUser.find(15)
338
+ # end
341
339
  #
342
- # -# file: app/views/users/show.haml
340
+ # -# file: app/views/users/show.haml
343
341
  #
344
- # %div[@user, :greeting]
345
- # %bar[290]/
346
- # Hello!
342
+ # %div[@user, :greeting]
343
+ # %bar[290]/
344
+ # Hello!
347
345
  #
348
346
  # is compiled to:
349
347
  #
350
- # <div class='greeting_crazy_user' id='greeting_crazy_user_15'>
351
- # <bar class='fixnum' id='fixnum_581' />
352
- # Hello!
353
- # </div>
348
+ # <div class='greeting_crazy_user' id='greeting_crazy_user_15'>
349
+ # <bar class='fixnum' id='fixnum_581' />
350
+ # Hello!
351
+ # </div>
354
352
  #
355
- # ==== > and <
353
+ # #### > and <
356
354
  #
357
- # <tt>></tt> and <tt><</tt> give you more control over the whitespace near a tag.
358
- # <tt>></tt> will remove all whitespace surrounding a tag,
359
- # while <tt><</tt> will remove all whitespace immediately within a tag.
355
+ # `>` and `<` give you more control over the whitespace near a tag.
356
+ # `>` will remove all whitespace surrounding a tag,
357
+ # while `<` will remove all whitespace immediately within a tag.
360
358
  # You can think of them as alligators eating the whitespace:
361
- # <tt>></tt> faces out of the tag and eats the whitespace on the outside,
362
- # and <tt><</tt> faces into the tag and eats the whitespace on the inside.
359
+ # `>` faces out of the tag and eats the whitespace on the outside,
360
+ # and `<` faces into the tag and eats the whitespace on the inside.
363
361
  # They're placed at the end of a tag definition,
364
362
  # after class, id, and attribute declarations
365
- # but before <tt>/</tt> or <tt>=</tt>.
363
+ # but before `/` or `=`.
366
364
  # For example:
367
365
  #
368
- # %blockquote<
369
- # %div
370
- # Foo!
366
+ # %blockquote<
367
+ # %div
368
+ # Foo!
371
369
  #
372
370
  # is compiled to:
373
371
  #
374
- # <blockquote><div>
375
- # Foo!
376
- # </div></blockquote>
372
+ # <blockquote><div>
373
+ # Foo!
374
+ # </div></blockquote>
377
375
  #
378
376
  # And:
379
377
  #
380
- # %img
381
- # %img>
382
- # %img
378
+ # %img
379
+ # %img>
380
+ # %img
383
381
  #
384
382
  # is compiled to:
385
383
  #
386
- # <img /><img /><img />
384
+ # <img /><img /><img />
387
385
  #
388
386
  # And:
389
387
  #
390
- # %p<= "Foo\nBar"
388
+ # %p<= "Foo\nBar"
391
389
  #
392
390
  # is compiled to:
393
391
  #
394
- # <p>Foo
395
- # Bar</p>
392
+ # <p>Foo
393
+ # Bar</p>
396
394
  #
397
395
  # And finally:
398
396
  #
399
- # %img
400
- # %pre><
401
- # foo
402
- # bar
403
- # %img
397
+ # %img
398
+ # %pre><
399
+ # foo
400
+ # bar
401
+ # %img
404
402
  #
405
403
  # is compiled to:
406
404
  #
407
- # <img /><pre>foo
408
- # bar</pre><img />
405
+ # <img /><pre>foo
406
+ # bar</pre><img />
409
407
  #
410
- # ==== =
408
+ # #### =
411
409
  #
412
- # <tt>=</tt> is placed at the end of a tag definition,
410
+ # `=` is placed at the end of a tag definition,
413
411
  # after class, id, and attribute declarations.
414
412
  # It's just a shortcut for inserting Ruby code into an element.
415
- # It works the same as <tt>=</tt> without a tag:
413
+ # It works the same as `=` without a tag:
416
414
  # it inserts the result of the Ruby code into the template.
417
415
  # However, if the result is short enough,
418
416
  # it is displayed entirely on one line.
419
417
  # For example:
420
418
  #
421
- # %p= "hello"
419
+ # %p= "hello"
422
420
  #
423
421
  # is not quite the same as:
424
422
  #
425
- # %p
426
- # = "hello"
423
+ # %p
424
+ # = "hello"
427
425
  #
428
426
  # It's compiled to:
429
427
  #
430
- # <p>hello</p>
428
+ # <p>hello</p>
431
429
  #
432
- # ==== #{}
430
+ # #### `#{}`
433
431
  #
434
- # Ruby code can also be interpolated within plain text using <tt>#{}</tt>,
432
+ # Ruby code can also be interpolated within plain text using `#{}`,
435
433
  # similarly to Ruby string interpolation.
436
434
  # For example,
437
435
  #
438
- # %p This is #{h quality} cake!
436
+ # %p This is #{h quality} cake!
439
437
  #
440
438
  # is the same as
441
439
  #
442
- # %p= "This is the #{h quality} cake!"
440
+ # %p= "This is the #{h quality} cake!"
443
441
  #
444
442
  # and might compile to
445
443
  #
446
- # <p>This is scrumptious cake!</p>
444
+ # <p>This is scrumptious cake!</p>
447
445
  #
448
- # Backslashes can be used to escape "#{" strings,
446
+ # Backslashes can be used to escape `#{` strings,
449
447
  # but they don't act as escapes anywhere else in the string.
450
448
  # For example:
451
449
  #
452
- # %p
453
- # \\ Look at \\#{h word} lack of backslash: \#{foo}
450
+ # %p
451
+ # Look at \\#{h word} lack of backslash: \#{foo}
452
+ # And yon presence thereof: \{foo}
454
453
  #
455
454
  # might compile to
456
455
  #
457
- # <p>
458
- # \\ Look at \yon lack of backslash: #{foo}
459
- # </p>
456
+ # <p>
457
+ # Look at \yon lack of backslash: #{foo}
458
+ # And yon presence thereof: \{foo}
459
+ # </p>
460
460
  #
461
- # ==== ~
461
+ # {#tilde}
462
+ # #### ~
462
463
  #
463
- # ~ works just like =, except that it runs Haml::Helpers#find_and_preserve on its input.
464
+ # `~` works just like `=`, except that it runs {Haml::Helpers#find\_and\_preserve} on its input.
464
465
  # For example,
465
466
  #
466
- # ~ "Foo\n<pre>Bar\nBaz</pre>"
467
+ # ~ "Foo\n<pre>Bar\nBaz</pre>"
467
468
  #
468
469
  # is the same as:
469
470
  #
470
- # = find_and_preserve("Foo\n<pre>Bar\nBaz</pre>")
471
+ # = find_and_preserve("Foo\n<pre>Bar\nBaz</pre>")
471
472
  #
472
473
  # and is compiled to:
473
474
  #
474
- # Foo
475
- # <pre>Bar&#x000A;Baz</pre>
475
+ # Foo
476
+ # <pre>Bar&#x000A;Baz</pre>
476
477
  #
477
- # See also Whitespace Preservation, below.
478
+ # See also [Whitespace Preservation](#whitespace_preservation).
478
479
  #
479
- # === XHTML Helpers
480
+ # ### XHTML Helpers
480
481
  #
481
- # ==== No Special Character
482
+ # #### No Special Character
482
483
  #
483
484
  # If no special character appears at the beginning of a line,
484
485
  # the line is rendered as plain text.
485
486
  # For example:
486
487
  #
487
- # %gee
488
- # %whiz
489
- # Wow this is cool!
488
+ # %gee
489
+ # %whiz
490
+ # Wow this is cool!
490
491
  #
491
492
  # is compiled to:
492
493
  #
493
- # <gee>
494
- # <whiz>
495
- # Wow this is cool!
496
- # </whiz>
497
- # </gee>
494
+ # <gee>
495
+ # <whiz>
496
+ # Wow this is cool!
497
+ # </whiz>
498
+ # </gee>
498
499
  #
499
- # ==== !!!
500
+ # #### !!!
500
501
  #
501
502
  # When describing XHTML documents with Haml,
502
503
  # you can have a document type or XML prolog generated automatically
503
- # by including the characters <tt>!!!</tt>.
504
+ # by including the characters `!!!`.
504
505
  # For example:
505
506
  #
506
- # !!! XML
507
- # !!!
508
- # %html
509
- # %head
510
- # %title Myspace
511
- # %body
512
- # %h1 I am the international space station
513
- # %p Sign my guestbook
507
+ # !!! XML
508
+ # !!!
509
+ # %html
510
+ # %head
511
+ # %title Myspace
512
+ # %body
513
+ # %h1 I am the international space station
514
+ # %p Sign my guestbook
514
515
  #
515
516
  # is compiled to:
516
517
  #
517
- # <?xml version='1.0' encoding='utf-8' ?>
518
- # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
519
- # <html>
520
- # <head>
521
- # <title>Myspace</title>
522
- # </head>
523
- # <body>
524
- # <h1>I am the international space station</h1>
525
- # <p>Sign my guestbook</p>
526
- # </body>
527
- # </html>
528
- #
529
- # You can also specify the version and type of XHTML after the <tt>!!!</tt>.
518
+ # <?xml version='1.0' encoding='utf-8' ?>
519
+ # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
520
+ # <html>
521
+ # <head>
522
+ # <title>Myspace</title>
523
+ # </head>
524
+ # <body>
525
+ # <h1>I am the international space station</h1>
526
+ # <p>Sign my guestbook</p>
527
+ # </body>
528
+ # </html>
529
+ #
530
+ # You can also specify the version and type of XHTML after the `!!!`.
530
531
  # XHTML 1.0 Strict, Transitional, and Frameset and XHTML 1.1 are supported.
531
532
  # The default version is 1.0 and the default type is Transitional.
532
533
  # For example:
533
534
  #
534
- # !!! 1.1
535
+ # !!! 1.1
535
536
  #
536
537
  # is compiled to:
537
538
  #
538
- # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
539
+ # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
539
540
  #
540
541
  # and
541
542
  #
542
- # !!! Strict
543
+ # !!! Strict
543
544
  #
544
545
  # is compiled to:
545
546
  #
546
- # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
547
+ # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
547
548
  #
548
549
  # while
549
550
  #
550
- # !!! Basic
551
+ # !!! Basic
551
552
  #
552
553
  # is compiled to:
553
554
  #
554
- # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
555
+ # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
555
556
  #
556
557
  # and
557
558
  #
558
- # !!! Mobile
559
+ # !!! Mobile
559
560
  #
560
561
  # is compiled to:
561
562
  #
562
- # <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">
563
+ # <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">
563
564
  #
564
565
  # If you're not using the UTF-8 character set for your document,
565
566
  # you can specify which encoding should appear
566
567
  # in the XML prolog in a similar way.
567
568
  # For example:
568
569
  #
569
- # !!! XML iso-8859-1
570
+ # !!! XML iso-8859-1
570
571
  #
571
572
  # is compiled to:
572
573
  #
573
- # <?xml version='1.0' encoding='iso-8859-1' ?>
574
+ # <?xml version='1.0' encoding='iso-8859-1' ?>
574
575
  #
575
- # ==== /
576
+ # #### /
576
577
  #
577
578
  # The forward slash character, when placed at the beginning of a line,
578
579
  # wraps all text after it in an HTML comment.
579
580
  # For example:
580
581
  #
581
- # %peanutbutterjelly
582
- # / This is the peanutbutterjelly element
583
- # I like sandwiches!
582
+ # %peanutbutterjelly
583
+ # / This is the peanutbutterjelly element
584
+ # I like sandwiches!
584
585
  #
585
586
  # is compiled to:
586
587
  #
587
- # <peanutbutterjelly>
588
- # <!-- This is the peanutbutterjelly element -->
589
- # I like sandwiches!
590
- # </peanutbutterjelly>
588
+ # <peanutbutterjelly>
589
+ # <!-- This is the peanutbutterjelly element -->
590
+ # I like sandwiches!
591
+ # </peanutbutterjelly>
591
592
  #
592
593
  # The forward slash can also wrap indented sections of code. For example:
593
594
  #
594
- # /
595
- # %p This doesn't render...
596
- # %div
597
- # %h1 Because it's commented out!
595
+ # /
596
+ # %p This doesn't render...
597
+ # %div
598
+ # %h1 Because it's commented out!
598
599
  #
599
600
  # is compiled to:
600
601
  #
601
- # <!--
602
- # <p>This doesn't render...</p>
603
- # <div>
604
- # <h1>Because it's commented out!</h1>
605
- # </div>
606
- # -->
602
+ # <!--
603
+ # <p>This doesn't render...</p>
604
+ # <div>
605
+ # <h1>Because it's commented out!</h1>
606
+ # </div>
607
+ # -->
607
608
  #
608
- # You can also use Internet Explorer conditional comments
609
- # (about)[http://www.quirksmode.org/css/condcom.html]
610
- # by enclosing the condition in square brackets after the <tt>/</tt>.
609
+ # You can also use [Internet Explorer conditional comments](http://www.quirksmode.org/css/condcom.html)
610
+ # by enclosing the condition in square brackets after the `/`.
611
611
  # For example:
612
612
  #
613
- # /[if IE]
614
- # %a{ :href => 'http://www.mozilla.com/en-US/firefox/' }
615
- # %h1 Get Firefox
613
+ # /[if IE]
614
+ # %a{ :href => 'http://www.mozilla.com/en-US/firefox/' }
615
+ # %h1 Get Firefox
616
616
  #
617
617
  # is compiled to:
618
618
  #
619
- # <!--[if IE]>
620
- # <a href='http://www.mozilla.com/en-US/firefox/'>
621
- # <h1>Get Firefox</h1>
622
- # </a>
623
- # <![endif]-->
619
+ # <!--[if IE]>
620
+ # <a href='http://www.mozilla.com/en-US/firefox/'>
621
+ # <h1>Get Firefox</h1>
622
+ # </a>
623
+ # <![endif]-->
624
624
  #
625
- # ==== \
625
+ # #### \
626
626
  #
627
627
  # The backslash character escapes the first character of a line,
628
628
  # allowing use of otherwise interpreted characters as plain text.
629
629
  # For example:
630
630
  #
631
- # %title
632
- # = @title
633
- # \- MySite
631
+ # %title
632
+ # = @title
633
+ # \- MySite
634
634
  #
635
635
  # is compiled to:
636
636
  #
637
- # <title>
638
- # MyPage
639
- # - MySite
640
- # </title>
637
+ # <title>
638
+ # MyPage
639
+ # - MySite
640
+ # </title>
641
641
  #
642
- # ==== |
642
+ # #### |
643
643
  #
644
644
  # The pipe character designates a multiline string.
645
645
  # It's placed at the end of a line (after some whitespace)
646
- # and means that all following lines that end with <tt>|</tt>
646
+ # and means that all following lines that end with `|`
647
647
  # will be evaluated as though they were on the same line.
648
648
  # For example:
649
649
  #
650
- # %whoo
651
- # %hoo I think this might get |
652
- # pretty long so I should |
653
- # probably make it |
654
- # multiline so it doesn't |
655
- # look awful. |
656
- # %p This is short.
650
+ # %whoo
651
+ # %hoo I think this might get |
652
+ # pretty long so I should |
653
+ # probably make it |
654
+ # multiline so it doesn't |
655
+ # look awful. |
656
+ # %p This is short.
657
657
  #
658
658
  # is compiled to:
659
659
  #
660
- # <whoo>
661
- # <hoo>
662
- # I think this might get pretty long so I should probably make it multiline so it doesn't look awful.
663
- # </hoo>
664
- # <p>This is short</p>
665
- # </whoo>
660
+ # <whoo>
661
+ # <hoo>
662
+ # I think this might get pretty long so I should probably make it multiline so it doesn't look awful.
663
+ # </hoo>
664
+ # <p>This is short</p>
665
+ # </whoo>
666
666
  #
667
- # ==== :
667
+ # #### :
668
668
  #
669
669
  # The colon character designates a filter.
670
670
  # This allows you to pass an indented block of text as input
@@ -672,230 +672,245 @@ require 'haml/version'
672
672
  # The syntax is simply a colon followed by the name of the filter.
673
673
  # For example,
674
674
  #
675
- # %p
676
- # :markdown
677
- # Textile
678
- # =======
675
+ # %p
676
+ # :markdown
677
+ # Textile
678
+ # =======
679
679
  #
680
- # Hello, *World*
680
+ # Hello, *World*
681
681
  #
682
682
  # is compiled to
683
683
  #
684
- # <p>
685
- # <h1>Textile</h1>
684
+ # <p>
685
+ # <h1>Textile</h1>
686
686
  #
687
- # <p>Hello, <em>World</em></p>
688
- # </p>
687
+ # <p>Hello, <em>World</em></p>
688
+ # </p>
689
689
  #
690
- # Filters can have Ruby code interpolated, like with ==.
690
+ # Filters can have Ruby code interpolated with `#{}`.
691
691
  # For example,
692
692
  #
693
- # - flavor = "raspberry"
694
- # #content
695
- # :textile
696
- # I *really* prefer _#{h flavor}_ jam.
693
+ # - flavor = "raspberry"
694
+ # #content
695
+ # :textile
696
+ # I *really* prefer _#{h flavor}_ jam.
697
697
  #
698
698
  # is compiled to
699
699
  #
700
- # <div id='content'>
701
- # <p>I <strong>really</strong> prefer <em>raspberry</em> jam.</p>
702
- # </div>
700
+ # <div id='content'>
701
+ # <p>I <strong>really</strong> prefer <em>raspberry</em> jam.</p>
702
+ # </div>
703
703
  #
704
704
  # Haml has the following filters defined:
705
705
  #
706
- # [plain] Does not parse the filtered text.
707
- # This is useful for large blocks of text without HTML tags,
708
- # when you don't want lines starting with <tt>.</tt> or <tt>-</tt>
709
- # to be parsed.
706
+ # {#plain-filter} plain
707
+ # : Does not parse the filtered text.
708
+ # This is useful for large blocks of text without HTML tags,
709
+ # when you don't want lines starting with `.` or `-` to be parsed.
710
710
  #
711
- # [javascript] Surrounds the filtered text with <script> and CDATA tags.
712
- # Useful for including inline Javascript.
711
+ # {#javascript-filter} javascript
712
+ # : Surrounds the filtered text with `<script>` and CDATA tags.
713
+ # Useful for including inline Javascript.
713
714
  #
714
- # [cdata] Surrounds the filtered text with CDATA tags.
715
+ # {#cdata-filter} cdata
716
+ # : Surrounds the filtered text with CDATA tags.
715
717
  #
716
- # [escaped] Works the same as plain, but HTML-escapes the text
717
- # before placing it in the document.
718
+ # {#escaped-filter} escaped
719
+ # : Works the same as plain, but HTML-escapes the text
720
+ # before placing it in the document.
718
721
  #
719
- # [ruby] Parses the filtered text with the normal Ruby interpreter.
720
- # All output sent to <tt>$stdout</tt>, like with +puts+,
721
- # is output into the Haml document.
722
- # Not available if the <tt>suppress_eval</tt> option is set to true.
723
- # The Ruby code is evaluated in the same context as the Haml template.
722
+ # {#ruby-filter} ruby
723
+ # : Parses the filtered text with the normal Ruby interpreter.
724
+ # All output sent to `$stdout`, like with `puts`,
725
+ # is output into the Haml document.
726
+ # Not available if the [`:suppress_eval`](#suppress_eval-option) option is set to true.
727
+ # The Ruby code is evaluated in the same context as the Haml template.
724
728
  #
725
- # [preserve] Inserts the filtered text into the template with whitespace preserved.
726
- # <tt>preserve</tt>d blocks of text aren't indented,
727
- # and newlines are replaced with the HTML escape code for newlines,
728
- # to preserve nice-looking output.
729
- # See also Whitespace Preservation, below.
729
+ # {#preserve-filter} preserve
730
+ # : Inserts the filtered text into the template with whitespace preserved.
731
+ # `preserve`d blocks of text aren't indented,
732
+ # and newlines are replaced with the HTML escape code for newlines,
733
+ # to preserve nice-looking output.
734
+ # See also [Whitespace Preservation](#whitespace_preservation).
730
735
  #
731
- # [erb] Parses the filtered text with ERB, like an RHTML template.
732
- # Not available if the <tt>suppress_eval</tt> option is set to true.
733
- # Embedded Ruby code is evaluated in the same context as the Haml template.
736
+ # {#erb-filter} erb
737
+ # : Parses the filtered text with ERB, like an RHTML template.
738
+ # Not available if the [`:suppress_eval`](#suppress_eval-option) option is set to true.
739
+ # Embedded Ruby code is evaluated in the same context as the Haml template.
734
740
  #
735
- # [sass] Parses the filtered text with Sass to produce CSS output.
741
+ # {#sass-filter} sass
742
+ # : Parses the filtered text with Sass to produce CSS output.
736
743
  #
737
- # [textile] Parses the filtered text with Textile (http://www.textism.com/tools/textile).
738
- # Only works if RedCloth is installed.
744
+ # {#textile-filter} textile
745
+ # : Parses the filtered text with [Textile](http://www.textism.com/tools/textile).
746
+ # Only works if [RedCloth](http://redcloth.org) is installed.
739
747
  #
740
- # [markdown] Parses the filtered text with Markdown (http://daringfireball.net/projects/markdown).
741
- # Only works if RDiscount, RPeg-Markdown, Maruku, or BlueCloth are installed.
748
+ # {#markdown-filter} markdown
749
+ # : Parses the filtered text with [Markdown](http://daringfireball.net/projects/markdown).
750
+ # Only works if [RDiscount](http://github.com/rtomayko/rdiscount),
751
+ # [RPeg-Markdown](http://github.com/rtomayko/rpeg-markdown),
752
+ # [Maruku](http://maruku.rubyforge.org),
753
+ # or [BlueCloth](www.deveiate.org/projects/BlueCloth) are installed.
742
754
  #
743
- # [maruku] Parses the filtered text with Maruku, which has some non-standard extensions to Markdown.
755
+ # {#maruku-filter} maruku
756
+ # : Parses the filtered text with [Maruku](http://maruku.rubyforge.org),
757
+ # which has some non-standard extensions to Markdown.
744
758
  #
745
- # You can also define your own filters (see Haml::Filters).
759
+ # You can also define your own filters (see {Haml::Filters}).
746
760
  #
747
- # === Ruby evaluators
761
+ # ### Ruby evaluators
748
762
  #
749
- # ==== =
763
+ # #### =
750
764
  #
751
765
  # The equals character is followed by Ruby code,
752
766
  # which is evaluated and the output inserted into the document as plain text.
753
767
  # For example:
754
768
  #
755
- # %p
756
- # = ['hi', 'there', 'reader!'].join " "
757
- # = "yo"
769
+ # %p
770
+ # = ['hi', 'there', 'reader!'].join " "
771
+ # = "yo"
758
772
  #
759
773
  # is compiled to:
760
774
  #
761
- # <p>
762
- # hi there reader!
763
- # yo
764
- # </p>
775
+ # <p>
776
+ # hi there reader!
777
+ # yo
778
+ # </p>
765
779
  #
766
- # If the <tt>:escape_html</tt> option is set, <tt>=</tt> will sanitize any
780
+ # If the [`:escape_html`](#escape_html-option) option is set, `=` will sanitize any
767
781
  # HTML-sensitive characters generated by the script. For example:
768
782
  #
769
- # = '<script>alert("I\'m evil!");</script>'
783
+ # = '<script>alert("I\'m evil!");</script>'
770
784
  #
771
785
  # would be compiled to
772
786
  #
773
- # &lt;script&gt;alert(&quot;I'm evil!&quot;);&lt;/script&gt;
787
+ # &lt;script&gt;alert(&quot;I'm evil!&quot;);&lt;/script&gt;
774
788
  #
775
- # ==== -
789
+ # #### -
776
790
  #
777
791
  # The hyphen character makes the text following it into "silent script":
778
792
  # Ruby script that is evaluated, but not output.
779
793
  #
780
- # <b>It is not recommended that you use this widely;
794
+ # **It is not recommended that you use this widely;
781
795
  # almost all processing code and logic should be restricted
782
- # to the Controller, the Helper, or partials.</b>
796
+ # to the Controller, the Helper, or partials.**
783
797
  #
784
798
  # For example:
785
799
  #
786
- # - foo = "hello"
787
- # - foo << " there"
788
- # - foo << " you!"
789
- # %p= foo
800
+ # - foo = "hello"
801
+ # - foo << " there"
802
+ # - foo << " you!"
803
+ # %p= foo
790
804
  #
791
805
  # is compiled to:
792
806
  #
793
- # <p>
794
- # hello there you!
795
- # </p>
807
+ # <p>
808
+ # hello there you!
809
+ # </p>
796
810
  #
797
- # ==== &=
811
+ # #### &=
798
812
  #
799
813
  # An ampersand followed by one or two equals characters
800
814
  # evaluates Ruby code just like the equals without the ampersand,
801
815
  # but sanitizes any HTML-sensitive characters in the result of the code.
802
816
  # For example:
803
817
  #
804
- # &= "I like cheese & crackers"
818
+ # &= "I like cheese & crackers"
805
819
  #
806
820
  # compiles to
807
821
  #
808
- # I like cheese &amp; crackers
822
+ # I like cheese &amp; crackers
809
823
  #
810
- # If the <tt>:escape_html</tt> option is set,
811
- # &= behaves identically to =.
824
+ # If the [`:escape_html`](#escape_html-option) option is set,
825
+ # `&=` behaves identically to `=`.
812
826
  #
813
- # & can also be used on its own so that <tt>#{}</tt> interpolation is escaped.
827
+ # `&` can also be used on its own so that `#{}` interpolation is escaped.
814
828
  # For example,
815
829
  #
816
- # & I like #{"cheese & crackers"}
830
+ # & I like #{"cheese & crackers"}
817
831
  #
818
832
  # compiles to
819
833
  #
820
- # I like cheese &amp; crackers
834
+ # I like cheese &amp; crackers
821
835
  #
822
- # ==== !=
836
+ # #### !=
823
837
  #
824
838
  # An exclamation mark followed by one or two equals characters
825
839
  # evaluates Ruby code just like the equals would,
826
840
  # but never sanitizes the HTML.
827
841
  #
828
842
  # By default, the single equals doesn't sanitize HTML either.
829
- # However, if the <tt>:escape_html</tt> option is set, = will sanitize the HTML, but != still won't.
830
- # For example, if <tt>:escape_html</tt> is set:
843
+ # However, if the [`:escape_html`](#escape_html-option) option is set,
844
+ # `=` will sanitize the HTML, but `!=` still won't.
845
+ # For example, if `:escape_html` is set:
831
846
  #
832
- # = "I feel <strong>!"
833
- # != "I feel <strong>!"
847
+ # = "I feel <strong>!"
848
+ # != "I feel <strong>!"
834
849
  #
835
850
  # compiles to
836
851
  #
837
- # I feel &lt;strong&gt;!
838
- # I feel <strong>!
852
+ # I feel &lt;strong&gt;!
853
+ # I feel <strong>!
839
854
  #
840
- # ! can also be used on its own so that <tt>#{}</tt> interpolation is unescaped.
855
+ # `!` can also be used on its own so that `#{}` interpolation is unescaped.
841
856
  # For example,
842
857
  #
843
- # ! I feel #{"<strong>"}!
858
+ # ! I feel #{"<strong>"}!
844
859
  #
845
860
  # compiles to
846
861
  #
847
- # I feel <strong>!
862
+ # I feel <strong>!
848
863
  #
849
- # ===== Blocks
864
+ # ##### Blocks
850
865
  #
851
866
  # Ruby blocks, like XHTML tags, don't need to be explicitly closed in Haml.
852
867
  # Rather, they're automatically closed, based on indentation.
853
868
  # A block begins whenever the indentation is increased
854
869
  # after a silent script command.
855
870
  # It ends when the indentation decreases
856
- # (as long as it's not an +else+ clause or something similar).
871
+ # (as long as it's not an `else` clause or something similar).
857
872
  # For example:
858
873
  #
859
- # - (42...47).each do |i|
860
- # %p= i
861
- # %p See, I can count!
874
+ # - (42...47).each do |i|
875
+ # %p= i
876
+ # %p See, I can count!
862
877
  #
863
878
  # is compiled to:
864
879
  #
865
- # <p>
866
- # 42
867
- # </p>
868
- # <p>
869
- # 43
870
- # </p>
871
- # <p>
872
- # 44
873
- # </p>
874
- # <p>
875
- # 45
876
- # </p>
877
- # <p>
878
- # 46
879
- # </p>
880
+ # <p>
881
+ # 42
882
+ # </p>
883
+ # <p>
884
+ # 43
885
+ # </p>
886
+ # <p>
887
+ # 44
888
+ # </p>
889
+ # <p>
890
+ # 45
891
+ # </p>
892
+ # <p>
893
+ # 46
894
+ # </p>
880
895
  #
881
896
  # Another example:
882
897
  #
883
- # %p
884
- # - case 2
885
- # - when 1
886
- # = "1!"
887
- # - when 2
888
- # = "2?"
889
- # - when 3
890
- # = "3."
898
+ # %p
899
+ # - case 2
900
+ # - when 1
901
+ # = "1!"
902
+ # - when 2
903
+ # = "2?"
904
+ # - when 3
905
+ # = "3."
891
906
  #
892
907
  # is compiled to:
893
908
  #
894
- # <p>
895
- # 2?
896
- # </p>
909
+ # <p>
910
+ # 2?
911
+ # </p>
897
912
  #
898
- # ==== -#
913
+ # #### -#
899
914
  #
900
915
  # The hyphen followed immediately by the pound sign
901
916
  # signifies a silent comment.
@@ -904,122 +919,122 @@ require 'haml/version'
904
919
  #
905
920
  # For example:
906
921
  #
907
- # %p foo
908
- # -# This is a comment
909
- # %p bar
922
+ # %p foo
923
+ # -# This is a comment
924
+ # %p bar
910
925
  #
911
926
  # is compiled to:
912
927
  #
913
- # <p>foo</p>
914
- # <p>bar</p>
928
+ # <p>foo</p>
929
+ # <p>bar</p>
915
930
  #
916
931
  # You can also nest text beneath a silent comment.
917
932
  # None of this text will be rendered.
918
933
  # For example:
919
934
  #
920
- # %p foo
921
- # -#
922
- # This won't be displayed
923
- # Nor will this
924
- # %p bar
935
+ # %p foo
936
+ # -#
937
+ # This won't be displayed
938
+ # Nor will this
939
+ # %p bar
925
940
  #
926
941
  # is compiled to:
927
942
  #
928
- # <p>foo</p>
929
- # <p>bar</p>
943
+ # <p>foo</p>
944
+ # <p>bar</p>
930
945
  #
931
- # == Other Useful Things
946
+ # ## Other Useful Things
932
947
  #
933
- # === Whitespace Preservation
948
+ # ### Whitespace Preservation
934
949
  #
935
950
  # Sometimes you don't want Haml to indent all your text.
936
- # For example, tags like +pre+ and +textarea+ are whitespace-sensitive;
951
+ # For example, tags like `pre` and `textarea` are whitespace-sensitive;
937
952
  # indenting the text makes them render wrong.
938
953
  #
939
954
  # Haml deals with this by "preserving" newlines before they're put into the document --
940
- # converting them to the XHTML whitespace escape code, <tt>&#x000A;</tt>.
955
+ # converting them to the XHTML whitespace escape code, `&#x000A;`.
941
956
  # Then Haml won't try to re-format the indentation.
942
957
  #
943
- # Literal +textarea+ and +pre+ tags automatically preserve their content.
958
+ # Literal `textarea` and `pre` tags automatically preserve their content.
944
959
  # Dynamically can't be caught automatically,
945
- # and so should be passed through Haml::Helpers#find_and_preserve or the <tt>~</tt> command,
946
- # which has the same effect (see above).
960
+ # and so should be passed through {Haml::Helpers#find\_and\_preserve} or the [`~` command](#tilde),
961
+ # which has the same effect.
947
962
  #
948
- # Blocks of literal text can be preserved using the :preserve filter (see above).
963
+ # Blocks of literal text can be preserved using the [`:preserve` filter](#preserve-filter).
949
964
  #
950
- # === Helpers
965
+ # ### Helpers
951
966
  #
952
967
  # Haml offers a bunch of helpers that are useful
953
968
  # for doing stuff like preserving whitespace,
954
969
  # creating nicely indented output for user-defined helpers,
955
970
  # and other useful things.
956
- # The helpers are all documented in the Haml::Helpers and Haml::Helpers::ActionViewExtensions modules.
971
+ # The helpers are all documented in the {Haml::Helpers} and {Haml::Helpers::ActionViewExtensions} modules.
957
972
  #
958
- # === Haml Options
973
+ # ### Haml Options
959
974
  #
960
- # Options can be set by setting the <tt>Haml::Template.options</tt> hash
961
- # in <tt>environment.rb</tt> in Rails...
975
+ # Options can be set by setting the {Haml::Template.options} hash
976
+ # in `environment.rb` in Rails...
962
977
  #
963
- # Haml::Template.options[:format] = :html5
978
+ # Haml::Template.options[:format] = :html5
964
979
  #
965
- # ...or by setting the <tt>Merb::Plugin.config[:haml]</tt> hash in <tt>init.rb</tt> in Merb...
980
+ # ...or by setting the `Merb::Plugin.config[:haml]` hash in `init.rb` in Merb...
966
981
  #
967
- # Merb::Plugin.config[:haml][:format] = :html5
982
+ # Merb::Plugin.config[:haml][:format] = :html5
968
983
  #
969
- # ...or by passing an options hash to Haml::Engine.new.
984
+ # ...or by passing an options hash to {Haml::Engine#initialize}.
970
985
  # Available options are:
971
986
  #
972
- # [<tt>:format</tt>] Determines the output format. The default is :xhtml.
973
- # Other options are :html4 and :html5, which are
974
- # identical to :xhtml except there are no self-closing tags,
975
- # XML prolog is ignored and correct DOCTYPEs are generated.
976
- #
977
- # [<tt>:escape_html</tt>] Sets whether or not to escape HTML-sensitive characters in script.
978
- # If this is true, = behaves like &=;
979
- # otherwise, it behaves like !=.
980
- # Note that if this is set, != should be used for yielding to subtemplates
981
- # and rendering partials.
982
- # Defaults to false.
983
- #
984
- # [<tt>:suppress_eval</tt>] Whether or not attribute hashes and Ruby scripts
985
- # designated by <tt>=</tt> or <tt>~</tt> should be
986
- # evaluated. If this is true, said scripts are
987
- # rendered as empty strings. Defaults to false.
988
- #
989
- # [<tt>:attr_wrapper</tt>] The character that should wrap element attributes.
990
- # This defaults to <tt>'</tt> (an apostrophe). Characters
991
- # of this type within the attributes will be escaped
992
- # (e.g. by replacing them with <tt>&apos;</tt>) if
993
- # the character is an apostrophe or a quotation mark.
994
- #
995
- # [<tt>:filename</tt>] The name of the Haml file being parsed.
996
- # This is only used as information when exceptions are raised.
997
- # This is automatically assigned when working through ActionView,
998
- # so it's really only useful for the user to assign
999
- # when dealing with Haml programatically.
1000
- #
1001
- # [<tt>:line</tt>] The line offset of the Haml template being parsed.
1002
- # This is useful for inline templates,
1003
- # similar to the last argument to Kernel#eval.
1004
- #
1005
- # [<tt>:autoclose</tt>] A list of tag names that should be automatically self-closed
1006
- # if they have no content.
1007
- # Defaults to <tt>['meta', 'img', 'link', 'br', 'hr', 'input', 'area', 'param', 'col', 'base']</tt>.
1008
- #
1009
- # [<tt>:preserve</tt>] A list of tag names that should automatically have their newlines preserved
1010
- # using the Haml::Helpers#preserve helper.
1011
- # This means that any content given on the same line as the tag will be preserved.
1012
- # For example:
1013
- #
1014
- # %textarea= "Foo\nBar"
1015
- #
1016
- # compiles to:
1017
- #
1018
- # <textarea>Foo&&#x000A;Bar</textarea>
1019
- #
1020
- # Defaults to <tt>['textarea', 'pre']</tt>.
1021
- #
1022
- # See also Whitespace Preservation, above.
987
+ # {#format-option} `:format`
988
+ # : Determines the output format. The default is `:xhtml`.
989
+ # Other options are `:html4` and `:html5`, which are
990
+ # identical to `:xhtml` except there are no self-closing tags,
991
+ # the XML prolog is ignored and correct DOCTYPEs are generated.
992
+ #
993
+ # {#escape_html-option} `:escape_html`
994
+ # : Sets whether or not to escape HTML-sensitive characters in script.
995
+ # If this is true, `=` behaves like `&=`;
996
+ # otherwise, it behaves like `!=`.
997
+ # Note that if this is set, `!=` should be used for yielding to subtemplates
998
+ # and rendering partials.
999
+ # Defaults to false.
1000
+ #
1001
+ # {#suppress_eval-option} `:suppress_eval`
1002
+ # : Whether or not attribute hashes and Ruby scripts
1003
+ # designated by `=` or `~` should be
1004
+ # evaluated. If this is `true`, said scripts are
1005
+ # rendered as empty strings. Defaults to `false`.
1006
+ #
1007
+ # {#attr_wrapper-option} `:attr_wrapper`
1008
+ # : The character that should wrap element attributes.
1009
+ # This defaults to `'` (an apostrophe). Characters
1010
+ # of this type within the attributes will be escaped
1011
+ # (e.g. by replacing them with `&apos;`) if
1012
+ # the character is an apostrophe or a quotation mark.
1013
+ #
1014
+ # {#filename-option} `:filename`
1015
+ # : The name of the Haml file being parsed.
1016
+ # This is only used as information when exceptions are raised.
1017
+ # This is automatically assigned when working through ActionView,
1018
+ # so it's really only useful for the user to assign
1019
+ # when dealing with Haml programatically.
1020
+ #
1021
+ # {#line-option} `:line`
1022
+ # : The line offset of the Haml template being parsed.
1023
+ # This is useful for inline templates,
1024
+ # similar to the last argument to `Kernel#eval`.
1025
+ #
1026
+ # {#autoclose-option} `:autoclose`
1027
+ # : A list of tag names that should be automatically self-closed
1028
+ # if they have no content.
1029
+ # Defaults to `['meta', 'img', 'link', 'br', 'hr', 'input', 'area', 'param', 'col', 'base']`.
1030
+ #
1031
+ # {#preserve-option} `:preserve`
1032
+ # : A list of tag names that should automatically have their newlines preserved
1033
+ # using the {Haml::Helpers#preserve} helper.
1034
+ # This means that any content given on the same line as the tag will be preserved.
1035
+ # For example, `%textarea= "Foo\nBar"` compiles to `<textarea>Foo&#x000A;Bar</textarea>`.
1036
+ # Defaults to `['textarea', 'pre']`.
1037
+ # See also [Whitespace Preservation](#whitespace_preservation).
1023
1038
  #
1024
1039
  module Haml
1025
1040
 
@@ -1029,11 +1044,17 @@ module Haml
1029
1044
  # A more fine-grained representation is available from Haml.version.
1030
1045
  VERSION = version[:string] unless defined?(Haml::VERSION)
1031
1046
 
1032
- # This method is called by init.rb,
1047
+ # Initializes Haml for Rails.
1048
+ #
1049
+ # This method is called by `init.rb`,
1033
1050
  # which is run by Rails on startup.
1034
- # We use it rather than putting stuff straight into init.rb
1051
+ # We use it rather than putting stuff straight into `init.rb`
1035
1052
  # so we can change the initialization behavior
1036
1053
  # without modifying the file itself.
1054
+ #
1055
+ # @param binding [Binding] The context of the `init.rb` file.
1056
+ # This isn't actually used;
1057
+ # it's just passed in in case it needs to be used in the future
1037
1058
  def self.init_rails(binding)
1038
1059
  # No &method here for Rails 2.1 compatibility
1039
1060
  %w[haml/template sass sass/plugin].each {|f| require f}