Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 1251 lines (866 sloc) 35.439 kB
33dd90f @mattwildig Update title of REFERENCE to HTML
mattwildig authored
1 # Haml (HTML Abstraction Markup Language)
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
2
f82de38 @norman Make HTML5 the default output format everywhere.
norman authored
3 Haml is a markup language that's used to cleanly and simply describe the HTML of
4 any web document, without the use of inline code. Haml functions as a
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
5 replacement for inline page templating systems such as PHP, ERB, and ASP.
6 However, Haml avoids the need for explicitly coding HTML into the template,
7 because it is actually an abstract description of the HTML, with some code to
8 generate dynamic content.
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
9
10 ## Features
11
12 * Whitespace active
13 * Well-formatted markup
14 * DRY
15 * Follows CSS conventions
16 * Integrates Ruby code
17 * Implements Rails templates with the .haml extension
18
19 ## Using Haml
20
21 Haml can be used in three ways:
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
22
23 * as a command-line tool,
24 * as a plugin for Ruby on Rails,
25 * and as a standalone Ruby module.
26
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
27 The first step for all of these is to install the Haml gem:
28
29 gem install haml
30
31 To run Haml from the command line, just use
32
33 haml input.haml output.html
34
35 Use `haml --help` for full documentation.
36
debd767 @norman Document options, remove some references to Merb
norman authored
37 To use Haml with Rails, add the following line to the Gemfile:
6bd452b @nex3 Change the recommended mode of Rails installation to config.gem or Ge…
nex3 authored
38
39 gem "haml"
908b15f @nex3 [Haml] Update reference with a plugin section.
nex3 authored
40
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
41 Once it's installed, all view files with the `".html.haml"` extension will be
42 compiled using Haml.
908b15f @nex3 [Haml] Update reference with a plugin section.
nex3 authored
43
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
44 You can access instance variables in Haml templates the same way you do in ERB
45 templates. Helper methods are also available in Haml templates. For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
46
47 # file: app/controllers/movies_controller.rb
48
49 class MoviesController < ApplicationController
50 def index
51 @title = "Teen Wolf"
52 end
53 end
54
debd767 @norman Document options, remove some references to Merb
norman authored
55 -# file: app/views/movies/index.html.haml
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
56
57 #content
58 .title
59 %h1= @title
60 = link_to 'Home', home_url
61
62 may be compiled to:
63
64 <div id='content'>
65 <div class='title'>
66 <h1>Teen Wolf</h1>
67 <a href='/'>Home</a>
68 </div>
69 </div>
70
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
71 ### Rails XSS Protection
c850140 @nex3 [Haml] Document the XSS support.
nex3 authored
72
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
73 Haml supports Rails' XSS protection scheme, which was introduced in Rails 2.3.5+
74 and is enabled by default in 3.0.0+. If it's enabled, Haml's
75 {Haml::Options#escape_html `:escape_html`} option is set to `true` by default -
76 like in ERB, all strings printed to a Haml template are escaped by default. Also
77 like ERB, strings marked as HTML safe are not escaped. Haml also has [its own
78 syntax for printing a raw string to the template](#unescaping_html).
c850140 @nex3 [Haml] Document the XSS support.
nex3 authored
79
80 If the `:escape_html` option is set to false when XSS protection is enabled,
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
81 Haml doesn't escape Ruby strings by default. However, if a string marked
82 HTML-safe is passed to [Haml's escaping syntax](#escaping_html), it won't be
83 escaped.
c850140 @nex3 [Haml] Document the XSS support.
nex3 authored
84
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
85 Finally, all the {Haml::Helpers Haml helpers} that return strings that are known
86 to be HTML safe are marked as such. In addition, string input is escaped unless
87 it's HTML safe.
c850140 @nex3 [Haml] Document the XSS support.
nex3 authored
88
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
89 ### Ruby Module
90
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
91 Haml can also be used completely separately from Rails and ActionView. To do
92 this, install the gem with RubyGems:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
93
94 gem install haml
95
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
96 You can then use it by including the "haml" gem in Ruby code, and using
97 {Haml::Engine} like so:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
98
99 engine = Haml::Engine.new("%p Haml code!")
100 engine.render #=> "<p>Haml code!</p>\n"
101
3847bea @nex3 Move the options documentation to a more prominent place.
nex3 authored
102 ### Options
103
debd767 @norman Document options, remove some references to Merb
norman authored
104 Haml understands various configuration options that affect its performance and
105 output.
3847bea @nex3 Move the options documentation to a more prominent place.
nex3 authored
106
18315b0 @norman Clarify how options should be set
norman authored
107 In Rails, options can be set by setting the {Haml::Template#options Haml::Template.options}
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
108 hash in an initializer:
debd767 @norman Document options, remove some references to Merb
norman authored
109
110 # config/initializers/haml.rb
3847bea @nex3 Move the options documentation to a more prominent place.
nex3 authored
111 Haml::Template.options[:format] = :html5
112
18315b0 @norman Clarify how options should be set
norman authored
113 Outside Rails, you can set them by configuring them globally in
114 Haml::Options.defaults:
debd767 @norman Document options, remove some references to Merb
norman authored
115
116 Haml::Options.defaults[:format] = :html5
117
118 Finally, you can also set them by passing an options hash to
119 {Haml::Engine#initialize}. For the complete list of available options, please
120 see {Haml::Options}.
76bd406 @nex3 [Haml] Add support for a workaround for fake ASCII input strings.
nex3 authored
121
ebaf1ba @nex3 [Haml] Add -# encoding: support.
nex3 authored
122 ### Encodings
123
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
124 When using Ruby 1.9 or later, Haml supports the same sorts of
125 encoding-declaration comments that Ruby does. Although both Ruby and Haml
126 support several different styles, the easiest it just to add `-# coding:
127 encoding-name` at the beginning of the Haml template (it must come before all
128 other lines). This will tell Haml that the template is encoded using the named
129 encoding.
ebaf1ba @nex3 [Haml] Add -# encoding: support.
nex3 authored
130
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
131 By default, the HTML generated by Haml has the same encoding as the Haml
132 template. However, if `Encoding.default_internal` is set, Haml will attempt to
133 use that instead. In addition, the [`:encoding` option](#encoding-option) can be
134 used to specify an output encoding manually.
ebaf1ba @nex3 [Haml] Add -# encoding: support.
nex3 authored
135
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
136 Note that, like Ruby, Haml does not support templates encoded in UTF-16 or
137 UTF-32, since these encodings are not compatible with ASCII. It is possible to
138 use these as the output encoding, though.
ebaf1ba @nex3 [Haml] Add -# encoding: support.
nex3 authored
139
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
140 ## Plain Text
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
141
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
142 A substantial portion of any HTML document is its content, which is plain old
143 text. Any Haml line that's not interpreted as something else is taken to be
144 plain text, and passed through unmodified. For example:
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
145
146 %gee
147 %whiz
148 Wow this is cool!
149
150 is compiled to:
151
152 <gee>
153 <whiz>
154 Wow this is cool!
155 </whiz>
156 </gee>
157
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
158 Note that HTML tags are passed through unmodified as well. If you have some HTML
159 you don't want to convert to Haml, or you're converting a file line-by-line, you
160 can just include it as-is. For example:
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
161
162 %p
163 <div id="blah">Blah!</div>
164
165 is compiled to:
166
167 <p>
168 <div id="blah">Blah!</div>
169 </p>
170
171 ### Escaping: `\`
172
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
173 The backslash character escapes the first character of a line, allowing use of
174 otherwise interpreted characters as plain text. For example:
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
175
176 %title
177 = @title
178 \= @title
179
180 is compiled to:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
181
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
182 <title>
183 MyPage
184 = @title
185 </title>
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
186
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
187 ## HTML Elements
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
188
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
189
190 ### Element Name: `%`
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
191
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
192 The percent character is placed at the beginning of a line. It's followed
193 immediately by the name of an element, then optionally by modifiers (see below),
194 a space, and text to be rendered inside the element. It creates an element in
195 the form of `<element></element>`. For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
196
197 %one
198 %two
199 %three Hey there
200
201 is compiled to:
202
203 <one>
204 <two>
205 <three>Hey there</three>
206 </two>
207 </one>
208
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
209 Any string is a valid element name; Haml will automatically generate opening and
210 closing tags for any element.
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
211
937cfed @nex3 [Haml] Add HTML-style attributes to the reference.
nex3 authored
212 ### Attributes: `{}` or `()` {#attributes}
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
213
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
214 Brackets represent a Ruby hash that is used for specifying the attributes of an
215 element. It is literally evaluated as a Ruby hash, so logic will work in it and
216 local variables may be used. Quote characters within the attribute will be
217 replaced by appropriate escape sequences. The hash is placed after the tag is
218 defined. For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
219
220 %html{:xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "en", :lang => "en"}
221
222 is compiled to:
223
224 <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'></html>
225
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
226 Attribute hashes can also be stretched out over multiple lines to accommodate
227 many attributes. However, newlines may only be placed immediately after commas.
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
228 For example:
229
230 %script{:type => "text/javascript",
231 :src => "javascripts/script_#{2 + 7}"}
232
233 is compiled to:
234
235 <script src='javascripts/script_9' type='text/javascript'></script>
236
782f44f @ronen [Haml] Allow :class and :id attributes to accept arrays, which will b…
ronen authored
237 #### `:class` and `:id` Attributes
238 {#class-and-id-attributes}
239
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
240 The `:class` and `:id` attributes can also be specified as a Ruby array whose
241 elements will be joined together. A `:class` array is joined with `" "` and an
242 `:id` array is joined with `"_"`. For example:
782f44f @ronen [Haml] Allow :class and :id attributes to accept arrays, which will b…
ronen authored
243
244 %div{:id => [@item.type, @item.number], :class => [@item.type, @item.urgency]}
245
246 is equivalent to:
247
248 %div{:id => "#{@item.type}_#{@item.number}", :class => "#{@item.type} #{@item.urgency}"}
249
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
250 The array will first be flattened and any elements that do not test as true will
251 be removed. The remaining elements will be converted to strings. For example:
782f44f @ronen [Haml] Allow :class and :id attributes to accept arrays, which will b…
ronen authored
252
253 %div{:class => [@item.type, @item == @sortcol && [:sort, @sortdir]] } Contents
254
255 could render as any of:
256
ec99bb5 @nex3 [Haml] Fix a small reference error.
nex3 authored
257 <div class="numeric sort ascending">Contents</div>
258 <div class="numeric">Contents</div>
259 <div class="sort descending">Contents</div>
260 <div>Contents</div>
782f44f @ronen [Haml] Allow :class and :id attributes to accept arrays, which will b…
ronen authored
261
18315b0 @norman Clarify how options should be set
norman authored
262 depending on whether `@item.type` is `"numeric"` or `nil`, whether `@item == @sortcol`,
782f44f @ronen [Haml] Allow :class and :id attributes to accept arrays, which will b…
ronen authored
263 and whether `@sortdir` is `"ascending"` or `"descending"`.
264
265 If a single value is specified and it evaluates to false it is ignored;
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
266 otherwise it gets converted to a string. For example:
782f44f @ronen [Haml] Allow :class and :id attributes to accept arrays, which will b…
ronen authored
267
268 .item{:class => @item.is_empty? && "empty"}
269
270 could render as either of:
271
272 class="item"
273 class="item empty"
274
937cfed @nex3 [Haml] Add HTML-style attributes to the reference.
nex3 authored
275 #### HTML-style Attributes: `()`
276
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
277 Haml also supports a terser, less Ruby-specific attribute syntax based on HTML's
278 attributes. These are used with parentheses instead of brackets, like so:
937cfed @nex3 [Haml] Add HTML-style attributes to the reference.
nex3 authored
279
280 %html(xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en")
281
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
282 Ruby variables can be used by omitting the quotes. Local variables or instance
283 variables can be used. For example:
937cfed @nex3 [Haml] Add HTML-style attributes to the reference.
nex3 authored
284
285 %a(title=@title href=href) Stuff
286
287 This is the same as:
288
289 %a{:title => @title, :href => href} Stuff
290
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
291 Because there are no commas separating attributes, though, more complicated
292 expressions aren't allowed. For those you'll have to use the `{}` syntax. You
293 can, however, use both syntaxes together:
937cfed @nex3 [Haml] Add HTML-style attributes to the reference.
nex3 authored
294
295 %a(title=@title){:href => @link.href} Stuff
296
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
297 You can also use `#{}` interpolation to insert complicated expressions in a
298 HTML-style attribute:
f5384c9 @nex3 [Haml] Update the reference again.
nex3 authored
299
300 %span(class="widget_#{@widget.number}")
301
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
302 HTML-style attributes can be stretched across multiple lines just like
303 hash-style attributes:
2585333 @nex3 [Haml] Tweak the reference a bit.
nex3 authored
304
305 %script(type="text/javascript"
306 src="javascripts/script_#{2 + 7}")
307
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
308 #### Ruby 1.9-style Hashes
309
310 On Ruby 1.9, Haml also supports Ruby's new hash syntax:
311
312 %a{title: @title, href: href} Stuff
313
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
314 #### Attribute Methods
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
315
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
316 A Ruby method call that returns a hash can be substituted for the hash contents.
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
317 For example, {Haml::Helpers} defines the following method:
318
319 def html_attrs(lang = 'en-US')
320 {:xmlns => "http://www.w3.org/1999/xhtml", 'xml:lang' => lang, :lang => lang}
321 end
322
323 This can then be used in Haml, like so:
324
325 %html{html_attrs('fr-fr')}
326
327 This is compiled to:
328
329 <html lang='fr-fr' xml:lang='fr-fr' xmlns='http://www.w3.org/1999/xhtml'>
330 </html>
331
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
332 You can use as many such attribute methods as you want by separating them with
333 commas, like a Ruby argument list. All the hashes will me merged together, from
334 left to right. For example, if you defined
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
335
336 def hash1
337 {:bread => 'white', :filling => 'peanut butter and jelly'}
338 end
339
340 def hash2
341 {:bread => 'whole wheat'}
342 end
343
344 then
345
346 %sandwich{hash1, hash2, :delicious => true}/
347
348 would compile to:
349
350 <sandwich bread='whole wheat' delicious='true' filling='peanut butter and jelly' />
351
352 Note that the Haml attributes list has the same syntax as a Ruby method call.
353 This means that any attribute methods must come before the hash literal.
354
937cfed @nex3 [Haml] Add HTML-style attributes to the reference.
nex3 authored
355 Attribute methods aren't supported for HTML-style attributes.
356
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
357 #### Boolean Attributes
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
358
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
359 Some attributes, such as "checked" for `input` tags or "selected" for `option`
360 tags, are "boolean" in the sense that their values don't matter - it only
361 matters whether or not they're present. In HTML (but not XHTML), these
362 attributes can be written as
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
363
364 <input selected>
365
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
366 To do this in Haml using hash-style attributes, just assign a Ruby `true` value
367 to the attribute:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
368
369 %input{:selected => true}
370
937cfed @nex3 [Haml] Add HTML-style attributes to the reference.
nex3 authored
371 In XHTML, the only valid value for these attributes is the name of the
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
372 attribute. Thus this will render in XHTML as
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
373
374 <input selected='selected'>
375
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
376 To set these attributes to false, simply assign them to a Ruby false value. In
377 both XHTML and HTML,
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
378
379 %input{:selected => false}
380
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
381 will just render as:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
382
383 <input>
384
937cfed @nex3 [Haml] Add HTML-style attributes to the reference.
nex3 authored
385 HTML-style boolean attributes can be written just like HTML:
386
387 %input(selected)
388
389 or using `true` and `false`:
390
391 %input(selected=true)
392
62f05fc @johnreilly [Haml] Added option for generating HTML5-style data-* attributes for …
johnreilly authored
393 #### HTML5 Custom Data Attributes
394
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
395 HTML5 allows for adding [custom non-visible data
396 attributes](http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#embedding-custom-non-visible-data)
397 to elements using attribute names beginning with `data-`. Custom data attributes
398 can be used in Haml by using the key `:data` with a Hash value in an attribute
399 hash. Each of the key/value pairs in the Hash will be transformed into a custom
400 data attribute. For example:
62f05fc @johnreilly [Haml] Added option for generating HTML5-style data-* attributes for …
johnreilly authored
401
402 %a{:href=>"/posts", :data => {:author_id => 123}} Posts By Author
403
404 will render as:
405
52a5eab @norman Hyphenate data attribute names by default
norman authored
406 <a data-author-id='123' href='/posts'>Posts By Author</a>
62f05fc @johnreilly [Haml] Added option for generating HTML5-style data-* attributes for …
johnreilly authored
407
52a5eab @norman Hyphenate data attribute names by default
norman authored
408 Notice that the underscore in `author_id` was replaced by a hyphen. If you wish
409 to suppress this behavior, you can set Haml's [`:hyphenate_data_attrs`
410 option](#hyphenate_data_attrs-option) to `false`, and the output will be
411 rendered as:
2f8c366 @fullsailor Updated the Changelog & Reference documents.
fullsailor authored
412
52a5eab @norman Hyphenate data attribute names by default
norman authored
413 <a data-author_id='123' href='/posts'>Posts By Author</a>
2f8c366 @fullsailor Updated the Changelog & Reference documents.
fullsailor authored
414
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
415 ### Class and ID: `.` and `#`
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
416
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
417 The period and pound sign are borrowed from CSS. They are used as shortcuts to
418 specify the `class` and `id` attributes of an element, respectively. Multiple
419 class names can be specified in a similar way to CSS, by chaining the class
420 names together with periods. They are placed immediately after the tag and
421 before an attributes hash. For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
422
423 %div#things
424 %span#rice Chicken Fried
425 %p.beans{ :food => 'true' } The magical fruit
426 %h1.class.otherclass#id La La La
427
428 is compiled to:
429
430 <div id='things'>
431 <span id='rice'>Chicken Fried</span>
432 <p class='beans' food='true'>The magical fruit</p>
433 <h1 class='class otherclass' id='id'>La La La</h1>
434 </div>
435
436 And,
437
a379f05 @ronen [Haml] Implicit divs were used in REFERENCE before they had been intr…
ronen authored
438 %div#content
439 %div.articles
440 %div.article.title Doogie Howser Comes Out
441 %div.article.date 2006-11-05
442 %div.article.entry
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
443 Neil Patrick Harris would like to dispel any rumors that he is straight
444
445 is compiled to:
446
447 <div id='content'>
448 <div class='articles'>
449 <div class='article title'>Doogie Howser Comes Out</div>
450 <div class='article date'>2006-11-05</div>
451 <div class='article entry'>
452 Neil Patrick Harris would like to dispel any rumors that he is straight
453 </div>
454 </div>
455 </div>
456
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
457 These shortcuts can be combined with long-hand attributes; the two values will
458 be merged together as though they were all placed in an array (see [the
459 documentation on `:class` and `:id` attributes](#class-and-id-attributes)). For
460 example:
782f44f @ronen [Haml] Allow :class and :id attributes to accept arrays, which will b…
ronen authored
461
462 %div#Article.article.entry{:id => @article.number, :class => @article.visibility}
463
464 is equivalent to
465
466 %div{:id => ['Article', @article.number], :class => ['article', 'entry', @article.visibility]} Gabba Hey
467
468 and could compile to:
469
470 <div class="article entry visible" id="Article_27">Gabba Hey</div>
471
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
472 #### Implicit Div Elements
473
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
474 Because divs are used so often, they're the default elements. If you only define
475 a class and/or id using `.` or `#`, a div is automatically used. For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
476
477 #collection
478 .item
479 .description What a cool item!
480
481 is the same as:
482
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
483 %div#collection
484 %div.item
485 %div.description What a cool item!
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
486
487 and is compiled to:
488
489 <div id='collection'>
490 <div class='item'>
491 <div class='description'>What a cool item!</div>
492 </div>
493 </div>
494
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
495 ### Self-Closing Tags: `/`
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
496
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
497 The forward slash character, when placed at the end of a tag definition, causes
498 the tag to be self-closed. For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
499
500 %br/
501 %meta{'http-equiv' => 'Content-Type', :content => 'text/html'}/
502
503 is compiled to:
504
505 <br />
506 <meta http-equiv='Content-Type' content='text/html' />
507
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
508 Some tags are automatically closed, as long as they have no content. `meta`,
509 `img`, `link`, `script`, `br`, and `hr` tags are closed by default. This list
510 can be customized by setting the [`:autoclose`](#autoclose-option) option. For
511 example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
512
513 %br
514 %meta{'http-equiv' => 'Content-Type', :content => 'text/html'}
515
516 is also compiled to:
517
518 <br />
519 <meta http-equiv='Content-Type' content='text/html' />
520
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
521 ### Whitespace Removal: `>` and `<`
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
522
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
523 `>` and `<` give you more control over the whitespace near a tag. `>` will
524 remove all whitespace surrounding a tag, while `<` will remove all whitespace
525 immediately within a tag. You can think of them as alligators eating the
526 whitespace: `>` faces out of the tag and eats the whitespace on the outside, and
527 `<` faces into the tag and eats the whitespace on the inside. They're placed at
528 the end of a tag definition, after class, id, and attribute declarations but
529 before `/` or `=`. For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
530
531 %blockquote<
532 %div
533 Foo!
534
535 is compiled to:
536
537 <blockquote><div>
538 Foo!
539 </div></blockquote>
540
541 And:
542
543 %img
544 %img>
545 %img
546
547 is compiled to:
548
549 <img /><img /><img />
550
551 And:
552
553 %p<= "Foo\nBar"
554
555 is compiled to:
556
557 <p>Foo
558 Bar</p>
559
560 And finally:
561
562 %img
563 %pre><
564 foo
565 bar
566 %img
567
568 is compiled to:
569
570 <img /><pre>foo
571 bar</pre><img />
572
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
573 ### Object Reference: `[]`
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
574
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
575 Square brackets follow a tag definition and contain a Ruby object that is used
576 to set the class and id of that tag. The class is set to the object's class
577 (transformed to use underlines rather than camel case) and the id is set to the
578 object's class, followed by the value of its `#to_key` or `#id` method (in that
579 order). This is most useful for elements that represent instances of Active
580 Model models. Additionally, the second argument (if present) will be used as a
581 prefix for both the id and class attributes. For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
582
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
583 # file: app/controllers/users_controller.rb
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
584
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
585 def show
586 @user = CrazyUser.find(15)
587 end
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
588
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
589 -# file: app/views/users/show.haml
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
590
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
591 %div[@user, :greeting]
592 %bar[290]/
593 Hello!
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
594
595 is compiled to:
596
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
597 <div class='greeting_crazy_user' id='greeting_crazy_user_15'>
598 <bar class='fixnum' id='fixnum_581' />
599 Hello!
600 </div>
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
601
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
602 If you require that the class be something other than the underscored object's
603 class, you can implement the `haml_object_ref` method on the object.
1e49eb1 @halorgium [Haml] Add support for overriding the object_ref of an Object.
halorgium authored
604
605 # file: app/models/crazy_user.rb
606
607 class CrazyUser < ActiveRecord::Base
608 def haml_object_ref
609 "a_crazy_user"
610 end
611 end
612
613 -# file: app/views/users/show.haml
614
615 %div[@user]
616 Hello!
617
618 is compiled to:
619
620 <div class='a_crazy_user' id='a_crazy_user_15'>
621 Hello!
622 </div>
623
624
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
625 ## Doctype: `!!!`
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
626
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
627 When describing HTML documents with Haml, you can have a document type or XML
628 prolog generated automatically by including the characters `!!!`. For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
629
630 !!! XML
631 !!!
632 %html
633 %head
634 %title Myspace
635 %body
636 %h1 I am the international space station
637 %p Sign my guestbook
638
639 is compiled to:
640
641 <?xml version='1.0' encoding='utf-8' ?>
642 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
643 <html>
644 <head>
645 <title>Myspace</title>
646 </head>
647 <body>
648 <h1>I am the international space station</h1>
649 <p>Sign my guestbook</p>
650 </body>
651 </html>
652
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
653 You can also specify the specific doctype after the `!!!` When the
f82de38 @norman Make HTML5 the default output format everywhere.
norman authored
654 [`:format`](#format-option) is set to `:xhtml`. The following doctypes are
655 supported:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
656
e1bed36 @nex3 [Haml] Improve the documentation for doctypes.
nex3 authored
657 `!!!`
658 : XHTML 1.0 Transitional<br/>
659 `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">`
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
660
e1bed36 @nex3 [Haml] Improve the documentation for doctypes.
nex3 authored
661 `!!! Strict`
662 : XHTML 1.0 Strict<br/>
663 `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">`
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
664
e1bed36 @nex3 [Haml] Improve the documentation for doctypes.
nex3 authored
665 `!!! Frameset`
666 : XHTML 1.0 Frameset<br/>
667 `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">`
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
668
2cd699f @nex3 [Haml] Support the XHTML5 doctype.
nex3 authored
669 `!!! 5`
670 : XHTML 5<br/>
671 `<!DOCTYPE html>`<br/>
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
672
e1bed36 @nex3 [Haml] Improve the documentation for doctypes.
nex3 authored
673 `!!! 1.1`
674 : XHTML 1.1<br/>
675 `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">`
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
676
e1bed36 @nex3 [Haml] Improve the documentation for doctypes.
nex3 authored
677 `!!! Basic`
678 : XHTML Basic 1.1<br/>
679 `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd"> `
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
680
e1bed36 @nex3 [Haml] Improve the documentation for doctypes.
nex3 authored
681 `!!! Mobile`
682 : XHTML Mobile 1.2<br/>
683 `<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">`
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
684
6448f06 @nex3 [Haml] Add an RDFa doctype shortcut.
nex3 authored
685 `!!! RDFa`
686 : XHTML+RDFa 1.0<br/>
687 `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">`
688
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
689 When the [`:format`](#format-option) option is set to `:html4`, the following
690 doctypes are supported:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
691
e1bed36 @nex3 [Haml] Improve the documentation for doctypes.
nex3 authored
692 `!!!`
693 : HTML 4.01 Transitional<br/>
694 `<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">`
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
695
e1bed36 @nex3 [Haml] Improve the documentation for doctypes.
nex3 authored
696 `!!! Strict`
697 : HTML 4.01 Strict<br/>
698 `<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">`
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
699
e1bed36 @nex3 [Haml] Improve the documentation for doctypes.
nex3 authored
700 `!!! Frameset`
701 : HTML 4.01 Frameset<br/>
702 `<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">`
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
703
f729a2c [Haml] Fix links to the format option in the reference.
huma authored
704 When the [`:format`](#format-option) option is set to `:html5`,
e1bed36 @nex3 [Haml] Improve the documentation for doctypes.
nex3 authored
705 `!!!` is always `<!DOCTYPE html>`.
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
706
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
707 If you're not using the UTF-8 character set for your document, you can specify
708 which encoding should appear in the XML prolog in a similar way. For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
709
710 !!! XML iso-8859-1
711
712 is compiled to:
713
714 <?xml version='1.0' encoding='iso-8859-1' ?>
715
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
716 If the mime_type of the template being rendered is `text/xml` then a format of
717 `:xhtml` will be used even if the global output format is set to `:html4` or
718 `:html5`.
12fdc50 @stepheneb force :xhtml if template.mime_type == 'text/xml'
stepheneb authored
719
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
720 ## Comments
721
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
722 Haml supports two sorts of comments: those that show up in the HTML output and
723 those that don't.
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
724
725 ### HTML Comments: `/`
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
726
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
727 The forward slash character, when placed at the beginning of a line, wraps all
728 text after it in an HTML comment. For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
729
730 %peanutbutterjelly
731 / This is the peanutbutterjelly element
732 I like sandwiches!
733
734 is compiled to:
735
736 <peanutbutterjelly>
737 <!-- This is the peanutbutterjelly element -->
738 I like sandwiches!
739 </peanutbutterjelly>
740
741 The forward slash can also wrap indented sections of code. For example:
742
743 /
744 %p This doesn't render...
745 %div
746 %h1 Because it's commented out!
747
748 is compiled to:
749
750 <!--
751 <p>This doesn't render...</p>
752 <div>
753 <h1>Because it's commented out!</h1>
754 </div>
755 -->
756
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
757 #### Conditional Comments: `/[]`
758
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
759 You can also use [Internet Explorer conditional
760 comments](http://www.quirksmode.org/css/condcom.html) by enclosing the condition
761 in square brackets after the `/`. For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
762
763 /[if IE]
764 %a{ :href => 'http://www.mozilla.com/en-US/firefox/' }
765 %h1 Get Firefox
766
767 is compiled to:
768
769 <!--[if IE]>
770 <a href='http://www.mozilla.com/en-US/firefox/'>
771 <h1>Get Firefox</h1>
772 </a>
773 <![endif]-->
774
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
775 ### Haml Comments: `-#`
776
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
777 The hyphen followed immediately by the pound sign signifies a silent comment.
778 Any text following this isn't rendered in the resulting document at all.
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
779
780 For example:
781
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
782 %p foo
783 -# This is a comment
784 %p bar
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
785
786 is compiled to:
787
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
788 <p>foo</p>
789 <p>bar</p>
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
790
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
791 You can also nest text beneath a silent comment. None of this text will be
792 rendered. For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
793
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
794 %p foo
795 -#
796 This won't be displayed
797 Nor will this
ce59af5 @norman Ignore indentation inside multiline comments
norman authored
798 Nor will this.
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
799 %p bar
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
800
801 is compiled to:
802
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
803 <p>foo</p>
804 <p>bar</p>
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
805
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
806 ## Ruby Evaluation
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
807
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
808 ### Inserting Ruby: `=`
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
809
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
810 The equals character is followed by Ruby code. This code is evaluated and the
811 output is inserted into the document. For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
812
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
813 %p
814 = ['hi', 'there', 'reader!'].join " "
815 = "yo"
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
816
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
817 is compiled to:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
818
819 <p>
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
820 hi there reader!
821 yo
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
822 </p>
823
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
824 If the [`:escape_html`](#escape_html-option) option is set, `=` will sanitize
825 any HTML-sensitive characters generated by the script. For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
826
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
827 = '<script>alert("I\'m evil!");</script>'
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
828
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
829 would be compiled to
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
830
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
831 &lt;script&gt;alert(&quot;I'm evil!&quot;);&lt;/script&gt;
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
832
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
833 `=` can also be used at the end of a tag to insert Ruby code within that tag.
834 For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
835
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
836 %p= "hello"
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
837
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
838 would be compiled to:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
839
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
840 <p>hello</p>
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
841
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
842 A line of Ruby code can be stretched over multiple lines as long as each line
843 but the last ends with a comma. For example:
bf7c593 @nex3 [Haml] Allow multiline Ruby blocks.
nex3 authored
844
845 = link_to_remote "Add to cart",
846 :url => { :action => "add", :id => product.id },
847 :update => { :success => "cart", :failure => "error" }
848
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
849 Note that it's illegal to nest code within a tag that ends with `=`.
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
850
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
851 ### Running Ruby: `-`
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
852
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
853 The hyphen character is also followed by Ruby code. This code is evaluated but
854 *not* inserted into the document.
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
855
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
856 **It is not recommended that you use this widely; almost all processing code and
857 logic should be restricted to Controllers, Helpers, or partials.**
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
858
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
859 For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
860
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
861 - foo = "hello"
862 - foo << " there"
863 - foo << " you!"
864 %p= foo
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
865
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
866 is compiled to:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
867
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
868 <p>
869 hello there you!
870 </p>
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
871
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
872 A line of Ruby code can be stretched over multiple lines as long as each line
873 but the last ends with a comma. For example:
bf7c593 @nex3 [Haml] Allow multiline Ruby blocks.
nex3 authored
874
875 - links = {:home => "/",
876 :docs => "/docs",
877 :about => "/about"}
878
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
879 #### Ruby Blocks
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
880
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
881 Ruby blocks, like XHTML tags, don't need to be explicitly closed in Haml.
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
882 Rather, they're automatically closed, based on indentation. A block begins
883 whenever the indentation is increased after a Ruby evaluation command. It ends
884 when the indentation decreases (as long as it's not an `else` clause or
885 something similar). For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
886
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
887 - (42...47).each do |i|
888 %p= i
889 %p See, I can count!
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
890
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
891 is compiled to:
892
e2fb73a @nex3 [Haml] Fix a bug in the reference.
nex3 authored
893 <p>42</p>
894 <p>43</p>
895 <p>44</p>
896 <p>45</p>
897 <p>46</p>
898 <p>See, I can count!</p>
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
899
900 Another example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
901
902 %p
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
903 - case 2
904 - when 1
905 = "1!"
906 - when 2
907 = "2?"
908 - when 3
909 = "3."
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
910
911 is compiled to:
912
913 <p>
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
914 2?
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
915 </p>
916
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
917 ### Whitespace Preservation: `~` {#tilde}
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
918
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
919 `~` works just like `=`, except that it runs {Haml::Helpers#find\_and\_preserve}
920 on its input. For example,
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
921
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
922 ~ "Foo\n<pre>Bar\nBaz</pre>"
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
923
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
924 is the same as:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
925
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
926 = find_and_preserve("Foo\n<pre>Bar\nBaz</pre>")
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
927
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
928 and is compiled to:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
929
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
930 Foo
931 <pre>Bar&#x000A;Baz</pre>
932
933 See also [Whitespace Preservation](#whitespace_preservation).
934
935 ### Ruby Interpolation: `#{}`
936
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
937 Ruby code can also be interpolated within plain text using `#{}`, similarly to
938 Ruby string interpolation. For example,
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
939
940 %p This is #{h quality} cake!
941
942 is the same as
943
944 %p= "This is the #{h quality} cake!"
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
945
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
946 and might compile to:
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
947
948 <p>This is scrumptious cake!</p>
949
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
950 Backslashes can be used to escape `#{}` strings, but they don't act as escapes
951 anywhere else in the string. For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
952
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
953 %p
954 Look at \\#{h word} lack of backslash: \#{foo}
955 And yon presence thereof: \{foo}
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
956
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
957 might compile to:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
958
959 <p>
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
960 Look at \yon lack of backslash: #{foo}
961 And yon presence thereof: \{foo}
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
962 </p>
963
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
964 Interpolation can also be used within [filters](#filters). For example:
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
965
966 :javascript
967 $(document).ready(function() {
968 alert(#{@message.to_json});
969 });
970
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
971 might compile to:
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
972
973 <script type='text/javascript'>
974 //<![CDATA[
975 $(document).ready(function() {
976 alert("Hi there!");
977 });
978 //]]>
979 </script>
980
f5384c9 @nex3 [Haml] Update the reference again.
nex3 authored
981 ### Escaping HTML: `&=` {#escaping_html}
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
982
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
983 An ampersand followed by one or two equals characters evaluates Ruby code just
984 like the equals without the ampersand, but sanitizes any HTML-sensitive
985 characters in the result of the code. For example:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
986
987 &= "I like cheese & crackers"
988
989 compiles to
990
991 I like cheese &amp; crackers
992
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
993 If the {Haml::Options#escape_html `:escape_html`} option is set, `&=` behaves
994 identically to `=`.
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
995
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
996 `&` can also be used on its own so that `#{}` interpolation is escaped. For
997 example,
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
998
999 & I like #{"cheese & crackers"}
1000
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
1001 compiles to:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
1002
1003 I like cheese &amp; crackers
1004
f5384c9 @nex3 [Haml] Update the reference again.
nex3 authored
1005 ### Unescaping HTML: `!=` {#unescaping_html}
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
1006
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
1007 An exclamation mark followed by one or two equals characters evaluates Ruby code
1008 just like the equals would, but never sanitizes the HTML.
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
1009
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
1010 By default, the single equals doesn't sanitize HTML either. However, if the
1011 {Haml::Options#escape_html `:escape_html`} option is set, `=` will sanitize the
1012 HTML, but `!=` still won't. For example, if `:escape_html` is set:
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
1013
1014 = "I feel <strong>!"
1015 != "I feel <strong>!"
1016
1017 compiles to
1018
1019 I feel &lt;strong&gt;!
1020 I feel <strong>!
1021
1022 `!` can also be used on its own so that `#{}` interpolation is unescaped.
1023 For example,
1024
1025 ! I feel #{"<strong>"}!
1026
1027 compiles to
1028
1029 I feel <strong>!
1030
dd4a067 @nex3 [Haml] Make the individual filters show up in the table of contents.
nex3 authored
1031 ## Filters {#filters}
91ae36a @nex3 Move around the Blocks section in the Haml reference.
nex3 authored
1032
3d5641c @norman Document filters. Load Maruku and Textile from contrib.
norman authored
1033 The colon character designates a filter. This allows you to pass an indented
1034 block of text as input to another filtering program and add the result to the
1035 output of Haml. The syntax is simply a colon followed by the name of the filter.
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
1036 For example:
91ae36a @nex3 Move around the Blocks section in the Haml reference.
nex3 authored
1037
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
1038 %p
1039 :markdown
3d5641c @norman Document filters. Load Maruku and Textile from contrib.
norman authored
1040 # Greetings
91ae36a @nex3 Move around the Blocks section in the Haml reference.
nex3 authored
1041
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
1042 Hello, *World*
91ae36a @nex3 Move around the Blocks section in the Haml reference.
nex3 authored
1043
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
1044 is compiled to:
91ae36a @nex3 Move around the Blocks section in the Haml reference.
nex3 authored
1045
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
1046 <p>
3d5641c @norman Document filters. Load Maruku and Textile from contrib.
norman authored
1047 <h1>Greetings</h1>
91ae36a @nex3 Move around the Blocks section in the Haml reference.
nex3 authored
1048
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
1049 <p>Hello, <em>World</em></p>
1050 </p>
91ae36a @nex3 Move around the Blocks section in the Haml reference.
nex3 authored
1051
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
1052 Filters can have Ruby code interpolated with `#{}`. For example:
91ae36a @nex3 Move around the Blocks section in the Haml reference.
nex3 authored
1053
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
1054 - flavor = "raspberry"
1055 #content
1056 :textile
3d5641c @norman Document filters. Load Maruku and Textile from contrib.
norman authored
1057 I *really* prefer _#{flavor}_ jam.
91ae36a @nex3 Move around the Blocks section in the Haml reference.
nex3 authored
1058
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
1059 is compiled to
91ae36a @nex3 Move around the Blocks section in the Haml reference.
nex3 authored
1060
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
1061 <div id='content'>
1062 <p>I <strong>really</strong> prefer <em>raspberry</em> jam.</p>
1063 </div>
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
1064
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
1065 Currently, filters ignore the {Haml::Options#escape_html `:escape_html`} option.
1066 This means that `#{}` interpolation within filters is never HTML-escaped.
6efc9ba @nex3 [Haml] Filters now don't respect :escape_html.
nex3 authored
1067
3d5641c @norman Document filters. Load Maruku and Textile from contrib.
norman authored
1068 The functionality of some filters such as Markdown can be provided by many
1069 different libraries. Usually you don't have to worry about this - you can just
1070 load the gem of your choice and Haml will automatically use it.
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
1071
bf9cd14 @norman Brought docs up to date, made REFERENCE formatting more consistent.
norman authored
1072 However in some cases you may want to make Haml explicitly use a specific gem to
1073 be used by a filter. In these cases you can do this via Tilt, the library Haml
1074 uses to implement many of its filters:
dd4a067 @nex3 [Haml] Make the individual filters show up in the table of contents.
nex3 authored
1075
3d5641c @norman Document filters. Load Maruku and Textile from contrib.
norman authored
1076 Tilt.prefer Tilt::RedCarpetTemplate
dd4a067 @nex3 [Haml] Make the individual filters show up in the table of contents.
nex3 authored
1077
3d5641c @norman Document filters. Load Maruku and Textile from contrib.
norman authored
1078 See the [Tilt documentation](https://github.com/rtomayko/tilt#fallback-mode) for
1079 more info.
1080
1081 Haml comes with the following filters defined:
7ef8110 @nex3 [Haml] Add a :css filter.
nex3 authored
1082
dd4a067 @nex3 [Haml] Make the individual filters show up in the table of contents.
nex3 authored
1083 {#cdata-filter}
1084 ### `:cdata`
1085 Surrounds the filtered text with CDATA tags.
1086
3d5641c @norman Document filters. Load Maruku and Textile from contrib.
norman authored
1087 {#coffee-filter}
1088 ### `:coffee`
1089 Compiles the filtered text to Javascript using Cofeescript. You can also
1090 reference this filter as `:coffeescript`. This filter is implemented using
1091 Tilt.
1092
1093 {#css-filter}
1094 ### `:css`
a520408 @mattwildig Document js and css filters handling of CDATA
mattwildig authored
1095 Surrounds the filtered text with `<style>` and (optionally) CDATA tags. Useful
1096 for including inline CSS. Use the {Haml::Options#cdata `:cdata` option} to
1097 control when CDATA tags are added.
3d5641c @norman Document filters. Load Maruku and Textile from contrib.
norman authored
1098
1099 {#erb-filter}
1100 ### `:erb`
1101 Parses the filtered text with ERb, like an RHTML template. Not available if the
1102 [`:suppress_eval`](#suppress_eval-option) option is set to true. Embedded Ruby
1103 code is evaluated in the same context as the Haml template. This filter is
1104 implemented using Tilt.
1105
dd4a067 @nex3 [Haml] Make the individual filters show up in the table of contents.
nex3 authored
1106 {#escaped-filter}
1107 ### `:escaped`
1108 Works the same as plain, but HTML-escapes the text
1109 before placing it in the document.
1110
3d5641c @norman Document filters. Load Maruku and Textile from contrib.
norman authored
1111 {#javascript-filter}
1112 ### `:javascript`
a520408 @mattwildig Document js and css filters handling of CDATA
mattwildig authored
1113 Surrounds the filtered text with `<script>` and (optionally) CDATA tags.
1114 Useful for including inline Javascript. Use the {Haml::Options#cdata `:cdata`
1115 option} to control when CDATA tags are added.
3d5641c @norman Document filters. Load Maruku and Textile from contrib.
norman authored
1116
1117 {#less-filter}
1118 ### `:less`
1119 Parses the filtered text with [Less](http://lesscss.org/) to produce CSS output.
1120 This filter is implemented using Tilt.
1121
1122
1123 {#markdown-filter}
1124 ### `:markdown`
1125 Parses the filtered text with
1126 [Markdown](http://daringfireball.net/projects/markdown). This filter is
1127 implemented using Tilt.
1128
1129 {#maruku-filter}
1130 ### `:maruku`
1131 Parses the filtered text with [Maruku](https://github.com/nex3/maruku), which
1132 has some non-standard extensions to Markdown.
1133
1134 As of Haml 3.2, this filter is defined in [Haml
1135 contrib](https://github.com/haml/haml-contrib) but is loaded automatically for
1136 historical reasons. In future versions of Haml it will likely not be loaded by
1137 default. This filter is implemented using Tilt.
1138
1139 {#plain-filter}
1140 ### `:plain`
1141 Does not parse the filtered text. This is useful for large blocks of text
1142 without HTML tags, when you don't want lines starting with `.` or `-` to be
1143 parsed.
dd4a067 @nex3 [Haml] Make the individual filters show up in the table of contents.
nex3 authored
1144
1145 {#preserve-filter}
1146 ### `:preserve`
1147 Inserts the filtered text into the template with whitespace preserved.
3d5641c @norman Document filters. Load Maruku and Textile from contrib.
norman authored
1148 `preserve`d blocks of text aren't indented, and newlines are replaced with the
1149 HTML escape code for newlines, to preserve nice-looking output. See also
1150 [Whitespace Preservation](#whitespace_preservation).
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
1151
3d5641c @norman Document filters. Load Maruku and Textile from contrib.
norman authored
1152 {#ruby-filter}
1153 ### `:ruby`
1154 Parses the filtered text with the normal Ruby interpreter. All output sent to
1155 `$stdout`, like with `puts`, is output into the Haml document. Not available if
1156 the [`:suppress_eval`](#suppress_eval-option) option is set to true. The Ruby
1157 code is evaluated in the same context as the Haml template.
dd4a067 @nex3 [Haml] Make the individual filters show up in the table of contents.
nex3 authored
1158
1159 {#sass-filter}
1160 ### `:sass`
3d5641c @norman Document filters. Load Maruku and Textile from contrib.
norman authored
1161 Parses the filtered text with [Sass](http://sass-lang.com/) to produce CSS
1162 output. This filter is implemented using Tilt.
dd4a067 @nex3 [Haml] Make the individual filters show up in the table of contents.
nex3 authored
1163
9e3574b @mattwildig Add SCSS filter.
mattwildig authored
1164 {#scss-filter}
1165 ### `:scss`
3d5641c @norman Document filters. Load Maruku and Textile from contrib.
norman authored
1166 Parses the filtered text with Sass like the `:sass` filter, but uses the newer
1167 SCSS syntax to produce CSS output. This filter is implemented using Tilt.
9e3574b @mattwildig Add SCSS filter.
mattwildig authored
1168
dd4a067 @nex3 [Haml] Make the individual filters show up in the table of contents.
nex3 authored
1169 {#textile-filter}
1170 ### `:textile`
1171 Parses the filtered text with [Textile](http://www.textism.com/tools/textile).
1172 Only works if [RedCloth](http://redcloth.org) is installed.
1173
3d5641c @norman Document filters. Load Maruku and Textile from contrib.
norman authored
1174 As of Haml 3.2, this filter is defined in [Haml
1175 contrib](https://github.com/haml/haml-contrib) but is loaded automatically for
1176 historical reasons. In future versions of Haml it will likely not be loaded by
1177 default. This filter is implemented using Tilt.
dd4a067 @nex3 [Haml] Make the individual filters show up in the table of contents.
nex3 authored
1178
1179 ### Custom Filters
1180
1181 You can also define your own filters. See {Haml::Filters} for details.
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
1182
5ae3231 @nex3 [Haml] Add an anchor for the multiline section of the reference.
nex3 authored
1183 ## Multiline: `|` {#multiline}
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
1184
1185 The pipe character designates a multiline string.
1186 It's placed at the end of a line (after some whitespace)
1187 and means that all following lines that end with `|`
1188 will be evaluated as though they were on the same line.
f1d849d @nex3 [Haml] Note multiline attribute hashes in the multiline section of th…
nex3 authored
1189 **Note that even the last line in the multiline block
132bdf5 @nex3 [Haml] Fix a small typo in the reference.
nex3 authored
1190 should end with `|`.**
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
1191 For example:
1192
1193 %whoo
6ff8c04 @nex3 [Haml] Fix a minor error in the reference.
nex3 authored
1194 %hoo= h( |
1195 "I think this might get " + |
1196 "pretty long so I should " + |
1197 "probably make it " + |
1198 "multiline so it doesn't " + |
1199 "look awful.") |
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
1200 %p This is short.
1201
1202 is compiled to:
1203
1204 <whoo>
6ff8c04 @nex3 [Haml] Fix a minor error in the reference.
nex3 authored
1205 <hoo>I think this might get pretty long so I should probably make it multiline so it doesn't look awful.</hoo>
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
1206 <p>This is short</p>
1207 </whoo>
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
1208
f1d849d @nex3 [Haml] Note multiline attribute hashes in the multiline section of th…
nex3 authored
1209 Using multiline declarations in Haml is intentionally awkward.
1210 This is designed to discourage people from putting lots and lots of Ruby code
1211 in their Haml templates.
1212 If you find yourself using multiline declarations, stop and think:
1213 could I do this better with a helper?
1214
bf7c593 @nex3 [Haml] Allow multiline Ruby blocks.
nex3 authored
1215 Note that there are a few cases where it's useful to allow
1216 something to flow over onto multiple lines in a non-awkward manner.
1217 One of these is HTML attributes.
f1d849d @nex3 [Haml] Note multiline attribute hashes in the multiline section of th…
nex3 authored
1218 Some elements just have lots of attributes,
1219 so you can wrap attributes without using `|` (see [Attributes](#attributes)).
1220
bf7c593 @nex3 [Haml] Allow multiline Ruby blocks.
nex3 authored
1221 In addition, sometimes you need to call Ruby methods or declare data structures
1222 that just need a lot of template information.
1223 So data structures and functions that require lots of arguments
1224 can be wrapped over multiple lines,
1225 as long as each line but the last ends in a comma
1226 (see [Inserting Ruby](#inserting_ruby_)).
1227
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
1228 ## Whitespace Preservation
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
1229
1230 Sometimes you don't want Haml to indent all your text.
1231 For example, tags like `pre` and `textarea` are whitespace-sensitive;
1232 indenting the text makes them render wrong.
1233
1234 Haml deals with this by "preserving" newlines before they're put into the document --
f82de38 @norman Make HTML5 the default output format everywhere.
norman authored
1235 converting them to the HTML whitespace escape code, `&#x000A;`.
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
1236 Then Haml won't try to re-format the indentation.
1237
5d7e90c @nex3 [Haml] Fix the reference w.r.t. exactly how pres and textareas auto-p…
nex3 authored
1238 Literal `textarea` and `pre` tags automatically preserve content given through `=`.
1239 Dynamically-generated `textarea`s and `pre`s can't be preserved automatically,
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
1240 and so should be passed through {Haml::Helpers#find\_and\_preserve} or the [`~` command](#tilde),
1241 which has the same effect.
1242
1243 Blocks of literal text can be preserved using the [`:preserve` filter](#preserve-filter).
1244
615dac7 @nex3 [Haml] Re-organize the reference.
nex3 authored
1245 ## Helpers
73dd210 @nex3 Move the Haml and Sass references into their own files.
nex3 authored
1246
3d5641c @norman Document filters. Load Maruku and Textile from contrib.
norman authored
1247 Haml offers a bunch of helpers that are useful for doing stuff like preserving
1248 whitespace, creating nicely indented output for user-defined helpers, and other
1249 useful things. The helpers are all documented in the {Haml::Helpers} and
1250 {Haml::Helpers::ActionViewExtensions} modules.
Something went wrong with that request. Please try again.