merbjedi-haml 2.1.0

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