haml 1.0.5 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of haml might be problematic. Click here for more details.

Files changed (92) hide show
  1. data/README +229 -0
  2. data/Rakefile +56 -60
  3. data/VERSION +1 -1
  4. data/bin/haml +4 -14
  5. data/bin/html2haml +89 -0
  6. data/bin/sass +8 -0
  7. data/init.rb +5 -1
  8. data/lib/haml.rb +643 -0
  9. data/lib/haml/buffer.rb +33 -30
  10. data/lib/haml/engine.rb +258 -75
  11. data/lib/haml/error.rb +43 -0
  12. data/lib/haml/exec.rb +181 -0
  13. data/lib/haml/filters.rb +89 -0
  14. data/lib/haml/helpers.rb +19 -5
  15. data/lib/haml/helpers/action_view_mods.rb +28 -4
  16. data/lib/haml/template.rb +13 -27
  17. data/lib/sass.rb +418 -0
  18. data/lib/sass/constant.rb +190 -0
  19. data/lib/sass/constant/color.rb +77 -0
  20. data/lib/sass/constant/literal.rb +51 -0
  21. data/lib/sass/constant/number.rb +87 -0
  22. data/lib/sass/constant/operation.rb +30 -0
  23. data/lib/sass/constant/string.rb +18 -0
  24. data/lib/sass/engine.rb +179 -0
  25. data/lib/sass/error.rb +35 -0
  26. data/lib/sass/plugin.rb +119 -0
  27. data/lib/sass/tree/attr_node.rb +44 -0
  28. data/lib/sass/tree/node.rb +29 -0
  29. data/lib/sass/tree/rule_node.rb +47 -0
  30. data/lib/sass/tree/value_node.rb +12 -0
  31. data/test/benchmark.rb +16 -19
  32. data/test/haml/engine_test.rb +220 -0
  33. data/test/{helper_test.rb → haml/helper_test.rb} +9 -8
  34. data/test/{mocks → haml/mocks}/article.rb +0 -0
  35. data/test/{results → haml/results}/content_for_layout.xhtml +0 -0
  36. data/test/{results → haml/results}/eval_suppressed.xhtml +0 -0
  37. data/test/haml/results/filters.xhtml +57 -0
  38. data/test/{results → haml/results}/helpers.xhtml +10 -0
  39. data/test/haml/results/helpful.xhtml +8 -0
  40. data/test/{results → haml/results}/just_stuff.xhtml +5 -0
  41. data/test/{results → haml/results}/list.xhtml +0 -0
  42. data/test/{results → haml/results}/original_engine.xhtml +1 -1
  43. data/test/{results → haml/results}/partials.xhtml +0 -0
  44. data/test/{results → haml/results}/silent_script.xhtml +0 -0
  45. data/test/{results → haml/results}/standard.xhtml +2 -1
  46. data/test/{results → haml/results}/tag_parsing.xhtml +0 -0
  47. data/test/{results → haml/results}/very_basic.xhtml +0 -0
  48. data/test/haml/results/whitespace_handling.xhtml +104 -0
  49. data/test/{rhtml → haml/rhtml}/standard.rhtml +4 -1
  50. data/test/{runner.rb → haml/runner.rb} +1 -1
  51. data/test/{template_test.rb → haml/template_test.rb} +28 -23
  52. data/test/{templates → haml/templates}/_partial.haml +0 -0
  53. data/test/{templates → haml/templates}/_text_area.haml +0 -0
  54. data/test/haml/templates/breakage.haml +8 -0
  55. data/test/{templates → haml/templates}/content_for_layout.haml +0 -0
  56. data/test/{templates → haml/templates}/eval_suppressed.haml +0 -0
  57. data/test/haml/templates/filters.haml +53 -0
  58. data/test/{templates → haml/templates}/helpers.haml +10 -1
  59. data/test/{templates → haml/templates}/helpful.haml +3 -0
  60. data/test/{templates → haml/templates}/just_stuff.haml +7 -0
  61. data/test/{templates → haml/templates}/list.haml +0 -0
  62. data/test/haml/templates/original_engine.haml +17 -0
  63. data/test/{templates → haml/templates}/partialize.haml +0 -0
  64. data/test/{templates → haml/templates}/partials.haml +0 -0
  65. data/test/{templates → haml/templates}/silent_script.haml +0 -0
  66. data/test/{templates → haml/templates}/standard.haml +3 -1
  67. data/test/{templates → haml/templates}/tag_parsing.haml +0 -0
  68. data/test/{templates → haml/templates}/very_basic.haml +0 -0
  69. data/test/haml/templates/whitespace_handling.haml +137 -0
  70. data/test/profile.rb +36 -18
  71. data/test/sass/engine_test.rb +87 -0
  72. data/test/sass/plugin_test.rb +103 -0
  73. data/test/sass/results/basic.css +9 -0
  74. data/test/sass/results/compact.css +5 -0
  75. data/test/sass/results/complex.css +86 -0
  76. data/test/sass/results/constants.css +12 -0
  77. data/test/sass/results/expanded.css +18 -0
  78. data/test/sass/results/nested.css +14 -0
  79. data/test/sass/templates/basic.sass +23 -0
  80. data/test/sass/templates/bork.sass +2 -0
  81. data/test/sass/templates/compact.sass +15 -0
  82. data/test/sass/templates/complex.sass +291 -0
  83. data/test/sass/templates/constants.sass +80 -0
  84. data/test/sass/templates/expanded.sass +15 -0
  85. data/test/sass/templates/nested.sass +15 -0
  86. metadata +98 -48
  87. data/REFERENCE +0 -662
  88. data/test/engine_test.rb +0 -93
  89. data/test/results/helpful.xhtml +0 -5
  90. data/test/results/whitespace_handling.xhtml +0 -51
  91. data/test/templates/original_engine.haml +0 -17
  92. data/test/templates/whitespace_handling.haml +0 -66
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.dirname(__FILE__) + '/../lib/haml'
4
+ require 'haml/engine'
5
+ require 'rubygems'
6
+ require 'hpricot'
7
+
8
+ def tabulate(tabs)
9
+ ' ' * tabs
10
+ end
11
+
12
+ TEXT_REGEXP = /^(\s*).*$/
13
+
14
+ def parse_text(text, tabs)
15
+ text.strip!
16
+ if text.empty?
17
+ String.new
18
+ else
19
+ lines = text.split("\n")
20
+
21
+ lines.map do |line|
22
+ line.strip!
23
+ "#{tabulate(tabs)}#{'\\' if Haml::Engine::SPECIAL_CHARACTERS.include?(line[0])}#{line}\n"
24
+ end.join
25
+ end
26
+ end
27
+
28
+ module Hpricot::Node
29
+ def to_haml(tabs)
30
+ parse_text(self.to_s, tabs)
31
+ end
32
+ end
33
+
34
+ class Hpricot::Doc
35
+ def to_haml
36
+ output = ''
37
+ children.each { |child| output += child.to_haml(0) }
38
+ output
39
+ end
40
+ end
41
+
42
+ class Hpricot::XMLDecl
43
+ def to_haml(tabs)
44
+ "#{tabulate(tabs)}!!! XML\n"
45
+ end
46
+ end
47
+
48
+ class Hpricot::DocType
49
+ def to_haml(tabs)
50
+ "#{tabulate(tabs)}!!!\n"
51
+ end
52
+ end
53
+
54
+ class Hpricot::Comment
55
+ def to_haml(tabs)
56
+ "#{tabulate(tabs)}/\n#{parse_text(self.content, tabs + 1)}"
57
+ end
58
+ end
59
+
60
+ class Hpricot::Elem
61
+ def to_haml(tabs)
62
+ output = "#{tabulate(tabs)}"
63
+ output += "%#{name}" unless name == 'div'
64
+
65
+ if attributes
66
+ output += "##{attributes['id']}" if attributes['id']
67
+ attributes['class'].split(' ').each { |c| output += ".#{c}" } if attributes['class']
68
+ attributes.delete("id")
69
+ attributes.delete("class")
70
+ output += attributes.inspect if attributes.length > 0
71
+ end
72
+
73
+ output += "/" if children.length == 0
74
+ output += "\n"
75
+
76
+ self.children.each do |child|
77
+ output += child.to_haml(tabs + 1)
78
+ end
79
+
80
+ output
81
+ end
82
+ end
83
+
84
+ # Must be required after Hpricot mods,
85
+ # so they're in scope
86
+ require 'haml/exec'
87
+
88
+ opts = Haml::Exec::HTML2Haml.new(ARGV)
89
+ opts.parse!
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # The command line Sass parser.
3
+
4
+ require File.dirname(__FILE__) + '/../lib/haml'
5
+ require 'haml/exec'
6
+
7
+ opts = Haml::Exec::Sass.new(ARGV)
8
+ opts.parse!
data/init.rb CHANGED
@@ -1,3 +1,7 @@
1
+ require 'haml'
1
2
  require 'haml/template'
3
+ require 'sass'
4
+ require 'sass/plugin'
2
5
 
3
- ActionView::Base.register_template_handler('haml', Haml::Template)
6
+ ActionView::Base.register_template_handler('haml', Haml::Template)
7
+ Sass::Plugin.update_stylesheets
@@ -0,0 +1,643 @@
1
+ dir = File.dirname(__FILE__)
2
+ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
3
+
4
+ # = Haml (XHTML Abstraction Markup Language)
5
+ #
6
+ # Haml is a markup language
7
+ # that's used to cleanly and simply describe the XHTML of any web document,
8
+ # without the use of inline code.
9
+ # Haml functions as a replacement
10
+ # for inline page templating systems such as PHP, ERB, and ASP.
11
+ # However, Haml avoids the need for explicitly coding XHTML into the template,
12
+ # because it is actually an abstract description of the XHTML,
13
+ # with some code to generate dynamic content.
14
+ #
15
+ # == Features
16
+ #
17
+ # * Whitespace active
18
+ # * Well-formatted markup
19
+ # * DRY
20
+ # * Follows CSS conventions
21
+ # * Integrates Ruby code
22
+ # * Implements Rails templates with the .haml extension
23
+ #
24
+ # == Using Haml
25
+ #
26
+ # Haml can be used in two ways:
27
+ # as a plugin for Ruby on Rails,
28
+ # and as a standalong Ruby module.
29
+ #
30
+ # === Rails
31
+ #
32
+ # Haml is most commonly used as a plugin.
33
+ # It can be installed as a plugin using the Rails plugin installer:
34
+ #
35
+ # ./script/plugin install http://svn.hamptoncatlin.com/haml/tags/stable
36
+ #
37
+ # Once it's installed, all view files with the ".haml" extension
38
+ # will be compiled using Haml.
39
+ #
40
+ # You can access instance variables in Haml templates
41
+ # the same way you do in ERb templates.
42
+ # Helper methods are also available in Haml templates.
43
+ # For example:
44
+ #
45
+ # # file: app/controllers/movies_controller.rb
46
+ #
47
+ # class MoviesController < ApplicationController
48
+ # def index
49
+ # @title = "Teen Wolf"
50
+ # end
51
+ # end
52
+ #
53
+ # # file: app/views/movies/index.haml
54
+ #
55
+ # #content
56
+ # .title
57
+ # %h1= @title
58
+ # = link_to 'Home', home_url
59
+ #
60
+ # may be compiled to:
61
+ #
62
+ # <div id='content'>
63
+ # <div class='title'>
64
+ # <h1>Teen Wolf</h1>
65
+ # <a href='/'>Home</a>
66
+ # </div>
67
+ # </div>
68
+ #
69
+ # === Ruby Module
70
+ #
71
+ # Haml can also be used completely separately from Rails and ActionView.
72
+ # To do this, install the gem with RubyGems:
73
+ #
74
+ # gem install haml
75
+ #
76
+ # You can then use it by including the "haml" gem in Ruby code,
77
+ # and using Haml::Engine like so:
78
+ #
79
+ # engine = Haml::Engine.new("%p Haml code!")
80
+ # engine.render #=> "<p>Haml code!</p>\n"
81
+ #
82
+ # == Characters with meaning to Haml
83
+ #
84
+ # Various characters, when placed at a certain point in a line,
85
+ # instruct Haml to render different types of things.
86
+ #
87
+ # === XHTML Tags
88
+ #
89
+ # These characters render XHTML tags.
90
+ #
91
+ # ==== %
92
+ #
93
+ #
94
+ # The percent character is placed at the beginning of a line.
95
+ # It's followed immediately by the name of an element,
96
+ # then optionally by modifiers (see below), a space,
97
+ # and text to be rendered inside the element.
98
+ # It creates an element in the form of <tt><element></element></tt>.
99
+ # For example:
100
+ #
101
+ # %one
102
+ # %two
103
+ # %three Hey there
104
+ #
105
+ # is compiled to:
106
+ #
107
+ # <one>
108
+ # <two>
109
+ # <three>Hey there</three>
110
+ # </two>
111
+ # </one>
112
+ #
113
+ # Any string is a valid element name;
114
+ # Haml will automatically generate opening and closing tags for any element.
115
+ #
116
+ # ==== {}
117
+ #
118
+ # Brackets represent a Ruby hash
119
+ # that is used for specifying the attributes of an element.
120
+ # It is literally evaluated as a Ruby hash,
121
+ # so logic will work in it and local variables may be used.
122
+ # Quote characters within the attribute
123
+ # will be replaced by appropriate escape sequences.
124
+ # The hash is placed after the tag is defined.
125
+ # For example:
126
+ #
127
+ # %head{ :name => "doc_head" }
128
+ # %script{ 'type' => "text/" + "javascript",
129
+ # :src => "javascripts/script_#{2 + 7}" }
130
+ #
131
+ # is compiled to:
132
+ #
133
+ # <head name="doc_head">
134
+ # <script src='javascripts/script_9' type='text/javascript'>
135
+ # </script>
136
+ # </head>
137
+ #
138
+ # ==== []
139
+ #
140
+ # Square brackets follow a tag definition and contain a Ruby object
141
+ # that is used to set the class and id of that tag.
142
+ # The class is set to the object's class
143
+ # (transformed to use underlines rather than camel case)
144
+ # and the id is set to the object's class, followed by its id.
145
+ # Because the id of an object is normally an obscure implementation detail,
146
+ # this is most useful for elements that represent instances of Models.
147
+ # For example:
148
+ #
149
+ # # file: app/controllers/users_controller.rb
150
+ #
151
+ # def show
152
+ # @user = CrazyUser.find(15)
153
+ # end
154
+ #
155
+ # # file: app/views/users/show.haml
156
+ #
157
+ # %div[@user]
158
+ # %bar[290]/
159
+ # Hello!
160
+ #
161
+ # is compiled to:
162
+ #
163
+ # <div class="crazy_user" id="crazy_user_15">
164
+ # <bar class="fixnum" id="fixnum_581" />
165
+ # Hello!
166
+ # </div>
167
+ #
168
+ # This is based off of DHH's SimplyHelpful syntax,
169
+ # as presented at RailsConf Europe 2006.
170
+ #
171
+ # ==== /
172
+ #
173
+ # The forward slash character, when placed at the end of a tag definition,
174
+ # causes the tag to be self-closed.
175
+ # For example:
176
+ #
177
+ # %br/
178
+ # %meta{'http-equiv' => 'Content-Type', :content => 'text/html'}/
179
+ #
180
+ # is compiled to:
181
+ #
182
+ # <br />
183
+ # <meta http-equiv='Content-Type' content='text/html' />
184
+ #
185
+ # ==== . and #
186
+ #
187
+ # The period and pound sign are borrowed from CSS.
188
+ # They are used as shortcuts to specify the <tt>class</tt>
189
+ # and <tt>id</tt> attributes of an element, respectively.
190
+ # Multiple class names can be specified in a similar way to CSS,
191
+ # by chaining the class names together with periods.
192
+ # They are placed immediately after the tag and before an attributes hash.
193
+ # For example:
194
+ #
195
+ # %div#things
196
+ # %span#rice Chicken Fried
197
+ # %p.beans{ :food => 'true' } The magical fruit
198
+ # %h1.class.otherclass#id La La La
199
+ #
200
+ # is compiled to:
201
+ #
202
+ # <div id='things'>
203
+ # <span id='rice'>Chicken Fried</span>
204
+ # <p class='beans' food='true'>The magical fruit</p>
205
+ # <h1 class='class otherclass' id='id'>La La La</h1>
206
+ # </div>
207
+ #
208
+ # And,
209
+ #
210
+ # #content
211
+ # .articles
212
+ # .article.title
213
+ # Doogie Howser Comes Out
214
+ # .article.date
215
+ # 2006-11-05
216
+ # .article.entry
217
+ # Neil Patrick Harris would like to dispel any rumors that he is straight
218
+ #
219
+ # is compiled to:
220
+ #
221
+ # <div id="content">
222
+ # <div class="articles">
223
+ # <div class="article title">Doogie Howser Comes Out</div>
224
+ # <div class="article date">2006-11-05</div>
225
+ # <div class="article entry">
226
+ # Neil Patrick Harris would like to dispel any rumors that he is straight
227
+ # </div>
228
+ # </div>
229
+ # </div>
230
+ #
231
+ # ==== Implicit Div Elements
232
+ #
233
+ # Because the div element is used so often, it is the default element.
234
+ # If you only define a class and/or id using the <tt>.</tt> or <tt>#</tt> syntax,
235
+ # a div element is automatically used.
236
+ # For example:
237
+ #
238
+ # #collection
239
+ # .item
240
+ # .description What a cool item!
241
+ #
242
+ # is the same as:
243
+ #
244
+ # %div{:id => collection}
245
+ # %div{:class => 'item'}
246
+ # %div{:class => 'description'} What a cool item!
247
+ #
248
+ # and is compiled to:
249
+ #
250
+ # <div id='collection'>
251
+ # <div class='item'>Broken record album</div>
252
+ # <div class='description'>What a cool item!</div>
253
+ # </div>
254
+ #
255
+ # ==== =
256
+ #
257
+ # <tt>=</tt> is placed at the end of a tag definition,
258
+ # after class, id, and attribute declarations.
259
+ # It's just a shortcut for inserting Ruby code into an element.
260
+ # It works the same as <tt>=</tt> without a tag:
261
+ # it inserts the result of the Ruby code into the template.
262
+ # However, if the result is short enough,
263
+ # it is displayed entirely on one line.
264
+ # For example:
265
+ #
266
+ # %p= "hello"
267
+ #
268
+ # is not quite the same as:
269
+ #
270
+ # %p
271
+ # = "hello"
272
+ #
273
+ # It's compiled to:
274
+ #
275
+ # <p>hello</p>
276
+ #
277
+ # === XHTML Helpers
278
+ #
279
+ # ==== No Special Character
280
+ #
281
+ # If no special character appears at the beginning of a line,
282
+ # the line is rendered as plain text.
283
+ # For example:
284
+ #
285
+ # %gee
286
+ # %whiz
287
+ # Wow this is cool!
288
+ #
289
+ # is compiled to:
290
+ #
291
+ # <gee>
292
+ # <whiz>
293
+ # Wow this is cool!
294
+ # </whiz>
295
+ # </gee>
296
+ #
297
+ # ==== !!!
298
+ #
299
+ # When describing XHTML documents with Haml,
300
+ # you can have a document type or XML prolog generated automatically
301
+ # by including the characters <tt>!!!</tt>.
302
+ # For example:
303
+ #
304
+ # !!! XML
305
+ # !!!
306
+ # %html
307
+ # %head
308
+ # %title Myspace
309
+ # %body
310
+ # %h1 I am the international space station
311
+ # %p Sign my guestbook
312
+ #
313
+ # is compiled to:
314
+ #
315
+ # <?xml version="1.0" encoding="utf-8" ?>
316
+ # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
317
+ # <html>
318
+ # <head>
319
+ # <title>Myspace</title>
320
+ # </head>
321
+ # <body>
322
+ # <h1>I am the international space station</h1>
323
+ # <p>Sign my guestbook</p>
324
+ # </body>
325
+ # </html>
326
+ #
327
+ # You can also specify the version and type of XHTML after the <tt>!!!</tt>.
328
+ # XHTML 1.0 Strict, Transitional, and Frameset and XHTML 1.1 are supported.
329
+ # The default version is 1.0 and the default type is Transitional.
330
+ # For example:
331
+ #
332
+ # !!! 1.1
333
+ #
334
+ # is compiled to:
335
+ #
336
+ # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
337
+ #
338
+ # and
339
+ #
340
+ # !!! Strict
341
+ #
342
+ # is compiled to:
343
+ #
344
+ # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
345
+ #
346
+ # If you're not using the UTF-8 characterset for your document,
347
+ # you can specify which encoding should appear
348
+ # in the XML prolog in a similar way.
349
+ # For example:
350
+ #
351
+ # !!! XML iso-8859-1
352
+ #
353
+ # is compiled to:
354
+ #
355
+ # <?xml version="1.0" encoding="iso-8859-1" ?>
356
+ #
357
+ # ==== /
358
+ #
359
+ # The forward slash character, when placed at the beginning of a line,
360
+ # wraps all text after it in an HTML comment.
361
+ # For example:
362
+ #
363
+ # %billabong
364
+ # / This is the billabong element
365
+ # I like billabongs!
366
+ #
367
+ # is compiled to:
368
+ #
369
+ # <billabong>
370
+ # <!-- This is the billabong element -->
371
+ # I like billabongs!
372
+ # </billabong>
373
+ #
374
+ # The forward slash can also wrap indented sections of code. For example:
375
+ #
376
+ # /
377
+ # %p This doesn't render...
378
+ # %div
379
+ # %h1 Because it's commented out!
380
+ #
381
+ # is compiled to:
382
+ #
383
+ # <!--
384
+ # <p>This doesn't render...</p>
385
+ # <div>
386
+ # <h1>Because it's commented out!</h1>
387
+ # </div>
388
+ # -->
389
+ #
390
+ # You can also use Internet Explorer conditional comments
391
+ # (about)[http://www.quirksmode.org/css/condcom.html]
392
+ # by enclosing the condition in square brackets after the <tt>/</tt>.
393
+ # For example:
394
+ #
395
+ # /[if IE]
396
+ # %a{ :href => 'http://www.mozilla.com/en-US/firefox/' }
397
+ # %h1 Get Firefox
398
+ #
399
+ # is compiled to:
400
+ #
401
+ # <!--[if IE]>
402
+ # <a href='http://www.mozilla.com/en-US/firefox/'>
403
+ # <h1>Get Firefox</h1>
404
+ # </a>
405
+ # <![endif]-->
406
+ #
407
+ # ==== \
408
+ #
409
+ # The backslash character escapes the first character of a line,
410
+ # allowing use of otherwise interpreted characters as plain text.
411
+ # For example:
412
+ #
413
+ # %title
414
+ # = @title
415
+ # \- MySite
416
+ #
417
+ # is compiled to:
418
+ #
419
+ # <title>
420
+ # MyPage
421
+ # - MySite
422
+ # </title>
423
+ #
424
+ # ==== |
425
+ #
426
+ # The pipe character designates a multiline string.
427
+ # It's placed at the end of a line
428
+ # and means that all following lines that end with <tt>|</tt>
429
+ # will be evaluated as though they were on the same line.
430
+ # For example:
431
+ #
432
+ # %whoo
433
+ # %hoo I think this might get |
434
+ # pretty long so I should |
435
+ # probably make it |
436
+ # multiline so it doesn't |
437
+ # look awful. |
438
+ # %p This is short.
439
+ #
440
+ # is compiled to:
441
+ #
442
+ # <whoo>
443
+ # <hoo>
444
+ # I think this might get pretty long so I should probably make it multiline so it doesn't look awful.
445
+ # </hoo>
446
+ # </whoo>
447
+ #
448
+ # ==== :
449
+ #
450
+ # The colon character designates a filter.
451
+ # This allows you to pass an indented block of text as input
452
+ # to another filtering program and add the result to the output of Haml.
453
+ # The syntax is simply a colon followed by the name of the filter.
454
+ # For example,
455
+ #
456
+ # %p
457
+ # :markdown
458
+ # Textile
459
+ # =======
460
+ #
461
+ # Hello, *World*
462
+ #
463
+ # is compiled to
464
+ #
465
+ # <p>
466
+ # <h1>Textile</h1>
467
+ #
468
+ # <p>Hello, <em>World</em></p>
469
+ # </p>
470
+ #
471
+ # Haml has the following filters defined:
472
+ #
473
+ # [plain] Does not parse the filtered text.
474
+ # This is useful for large blocks of text without HTML tags,
475
+ # when you don't want lines starting with <tt>.</tt> or <tt>-</tt>
476
+ # to be parsed.
477
+ #
478
+ # [ruby] Parses the filtered text with the normal Ruby interpreter.
479
+ # All output sent to <tt>$stdout</tt>, like with +puts+,
480
+ # is output into the Haml document.
481
+ # Not available if the <tt>suppress_eval</tt> option is set to true.
482
+ #
483
+ # [preserve] Inserts the filtered text into the template with whitespace preserved.
484
+ # <tt>preserve</tt>d blocks of text aren't indented,
485
+ # and newlines are replaced with the HTML escape code for newlines,
486
+ # to preserve nice-looking output.
487
+ #
488
+ # [erb] Parses the filtered text with ERB, like an RHTML template.
489
+ # Not available if the <tt>suppress_eval</tt> option is set to true.
490
+ # At the moment, this doesn't support access to variables
491
+ # defined by Ruby on Rails or Haml code.
492
+ #
493
+ # [sass] Parses the filtered text with Sass to produce CSS output.
494
+ #
495
+ # [redcloth] Parses the filtered text with RedCloth (http://whytheluckystiff.net/ruby/redcloth),
496
+ # which uses both Textile and Markdown syntax.
497
+ # Only works if RedCloth is installed.
498
+ #
499
+ # [textile] Parses the filtered text with Textile (http://www.textism.com/tools/textile).
500
+ # Only works if RedCloth is installed.
501
+ #
502
+ # [markdown] Parses the filtered text with Markdown (http://daringfireball.net/projects/markdown).
503
+ # Only works if RedCloth or BlueCloth (http://www.deveiate.org/projects/BlueCloth)
504
+ # is installed
505
+ # (BlueCloth takes precedence if both are installed).
506
+ #
507
+ # You can also define your own filters (see Setting Options, below).
508
+ #
509
+ # === Ruby evaluators
510
+ #
511
+ # ==== =
512
+ #
513
+ # The equals character is followed by Ruby code,
514
+ # which is evaluated and the output inserted into the document as plain text.
515
+ # For example:
516
+ #
517
+ # %p
518
+ # = ['hi', 'there', 'reader!'].join " "
519
+ # = "yo"
520
+ #
521
+ # is compiled to:
522
+ #
523
+ # <p>
524
+ # hi there reader!
525
+ # yo
526
+ # </p>
527
+ #
528
+ # ==== -
529
+ #
530
+ # The hyphen character makes the text following it into "silent script":
531
+ # Ruby script that is evaluated, but not output.
532
+ #
533
+ # <b>It is not recommended that you use this widely;
534
+ # almost all processing code and logic should be restricted
535
+ # to the Controller, the Helper, or partials.</b>
536
+ #
537
+ # For example:
538
+ #
539
+ # - foo = "hello"
540
+ # - foo << " there"
541
+ # - foo << " you!"
542
+ # %p= foo
543
+ #
544
+ # is compiled to:
545
+ #
546
+ # <p>
547
+ # hello there you!
548
+ # </p>
549
+ #
550
+ # ===== Blocks
551
+ #
552
+ # Ruby blocks, like XHTML tags, don't need to be explicitly closed in Haml.
553
+ # Rather, they're automatically closed, based on indentation.
554
+ # A block begins whenever the indentation is increased
555
+ # after a silent script command.
556
+ # It ends when the indentation decreases
557
+ # (as long as it's not an +else+ clause or something similar).
558
+ # For example:
559
+ #
560
+ # - (42...47).each do |i|
561
+ # %p= i
562
+ # %p See, I can count!
563
+ #
564
+ # is compiled to:
565
+ #
566
+ # <p>
567
+ # 42
568
+ # </p>
569
+ # <p>
570
+ # 43
571
+ # </p>
572
+ # <p>
573
+ # 44
574
+ # </p>
575
+ # <p>
576
+ # 45
577
+ # </p>
578
+ # <p>
579
+ # 46
580
+ # </p>
581
+ #
582
+ # Another example:
583
+ #
584
+ # %p
585
+ # - case 2
586
+ # - when 1
587
+ # = "1!"
588
+ # - when 2
589
+ # = "2?"
590
+ # - when 3
591
+ # = "3."
592
+ #
593
+ # is compiled to:
594
+ #
595
+ # <p>
596
+ # 2?
597
+ # </p>
598
+ #
599
+ # == Haml Options
600
+ #
601
+ # Options can be set by setting the hash <tt>Haml::Template.options</tt>
602
+ # from <tt>environment.rb</tt> in Rails,
603
+ # or by passing an options hash to Haml::Engine.
604
+ # Available options are:
605
+ #
606
+ # [<tt>:suppress_eval</tt>] Whether or not attribute hashes and Ruby scripts
607
+ # designated by <tt>=</tt> or <tt>~</tt> should be
608
+ # evaluated. If this is true, said scripts are
609
+ # rendered as empty strings. Defaults to false.
610
+ #
611
+ # [<tt>:precompiled</tt>] A string containing a precompiled Haml template.
612
+ # If this is passed, <tt>template</tt> is ignored
613
+ # and no precompilation is done.
614
+ #
615
+ # [<tt>:attr_wrapper</tt>] The character that should wrap element attributes.
616
+ # This defaults to <tt>'</tt> (an apostrophe). Characters
617
+ # of this type within the attributes will be escaped
618
+ # (e.g. by replacing them with <tt>&apos;</tt>) if
619
+ # the character is an apostrophe or a quotation mark.
620
+ #
621
+ # [<tt>:filename</tt>] The name of the Haml file being parsed.
622
+ # This is only used as information when exceptions are raised.
623
+ # This is automatically assigned when working through ActionView,
624
+ # so it's really only useful for the user to assign
625
+ # when dealing with Haml programatically.
626
+ #
627
+ # [<tt>:filters</tt>] A hash of filters that can be applied to Haml code.
628
+ # The keys are the string names of the filters;
629
+ # the values are references to the classes of the filters.
630
+ # User-defined filters should always have lowercase keys,
631
+ # and should have:
632
+ # * An +initialize+ method that accepts one parameter,
633
+ # the text to be filtered.
634
+ # * A +render+ method that returns the result of the filtering.
635
+ #
636
+ # [<tt>:locals</tt>] The local variables that will be available within the
637
+ # template. For instance, if <tt>:locals</tt> is
638
+ # <tt>{ :foo => "bar" }</tt>, then within the template,
639
+ # <tt>= foo</tt> will produce <tt>bar</tt>.
640
+ #
641
+ module Haml; end
642
+
643
+ require 'haml/engine'