haml 2.0.10 → 2.2.0

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

Potentially problematic release.


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

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