haml 3.2.0.alpha.10 → 3.2.0.alpha.13

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 (389) hide show
  1. data/.yardopts +19 -7
  2. data/CHANGELOG.md +1224 -0
  3. data/FAQ.md +157 -0
  4. data/README.md +99 -62
  5. data/REFERENCE.md +1404 -0
  6. data/Rakefile +52 -341
  7. data/init.rb +1 -18
  8. data/lib/haml.rb +6 -30
  9. data/lib/haml/buffer.rb +37 -16
  10. data/lib/haml/compiler.rb +52 -13
  11. data/lib/haml/engine.rb +61 -44
  12. data/lib/haml/exec.rb +21 -4
  13. data/lib/haml/filters.rb +136 -166
  14. data/lib/haml/helpers.rb +37 -10
  15. data/lib/haml/helpers/action_view_extensions.rb +2 -1
  16. data/lib/haml/helpers/action_view_mods.rb +67 -181
  17. data/lib/haml/helpers/rails_323_textarea_fix.rb +39 -0
  18. data/lib/haml/helpers/xss_mods.rb +9 -11
  19. data/lib/haml/html.rb +22 -9
  20. data/lib/haml/html/erb.rb +1 -1
  21. data/lib/haml/parser.rb +22 -15
  22. data/lib/haml/railtie.rb +2 -13
  23. data/lib/haml/template.rb +18 -85
  24. data/lib/haml/template/options.rb +1 -1
  25. data/lib/haml/template/plugin.rb +15 -101
  26. data/lib/haml/util.rb +120 -603
  27. data/lib/haml/version.rb +1 -107
  28. data/test/{haml/engine_test.rb → engine_test.rb} +137 -143
  29. data/test/{haml/erb → erb}/_av_partial_1.erb +1 -1
  30. data/test/{haml/erb → erb}/_av_partial_2.erb +1 -1
  31. data/test/{haml/erb → erb}/action_view.erb +1 -1
  32. data/test/{haml/erb → erb}/standard.erb +0 -0
  33. data/test/filters_test.rb +141 -0
  34. data/test/gemfiles/Gemfile.rails-3.0.x +4 -6
  35. data/test/gemfiles/Gemfile.rails-3.1.x +5 -6
  36. data/test/gemfiles/Gemfile.rails-3.2.x +6 -0
  37. data/test/haml-spec/LICENSE +14 -0
  38. data/test/{haml/spec → haml-spec}/README.md +26 -17
  39. data/test/haml-spec/lua_haml_spec.lua +38 -0
  40. data/test/haml-spec/perl_haml_test.pl +81 -0
  41. data/test/haml-spec/ruby_haml_test.rb +23 -0
  42. data/test/{haml/spec → haml-spec}/tests.json +132 -54
  43. data/test/{haml/helper_test.rb → helper_test.rb} +50 -36
  44. data/test/{haml/html2haml → html2haml}/erb_tests.rb +0 -0
  45. data/test/{haml/html2haml_test.rb → html2haml_test.rb} +11 -5
  46. data/test/{haml/markaby → markaby}/standard.mab +0 -0
  47. data/test/{haml/mocks → mocks}/article.rb +0 -0
  48. data/test/{haml/results → results}/content_for_layout.xhtml +0 -0
  49. data/test/{haml/results → results}/eval_suppressed.xhtml +0 -0
  50. data/test/{haml/results → results}/helpers.xhtml +0 -0
  51. data/test/{haml/results → results}/helpful.xhtml +0 -0
  52. data/test/{haml/results → results}/just_stuff.xhtml +0 -0
  53. data/test/{haml/results → results}/list.xhtml +0 -0
  54. data/test/{haml/results → results}/nuke_inner_whitespace.xhtml +0 -0
  55. data/test/{haml/results → results}/nuke_outer_whitespace.xhtml +0 -0
  56. data/test/{haml/results → results}/original_engine.xhtml +0 -0
  57. data/test/{haml/results → results}/partial_layout.xhtml +0 -0
  58. data/test/{haml/results → results}/partials.xhtml +0 -0
  59. data/test/{haml/results → results}/render_layout.xhtml +0 -0
  60. data/test/{haml/results → results}/silent_script.xhtml +1 -1
  61. data/test/{haml/results → results}/standard.xhtml +0 -0
  62. data/test/{haml/results → results}/tag_parsing.xhtml +0 -0
  63. data/test/{haml/results → results}/very_basic.xhtml +0 -0
  64. data/test/{haml/results → results}/whitespace_handling.xhtml +46 -50
  65. data/test/{haml/template_test.rb → template_test.rb} +20 -81
  66. data/test/{haml/templates → templates}/_av_partial_1.haml +1 -1
  67. data/test/{haml/templates → templates}/_av_partial_1_ugly.haml +1 -1
  68. data/test/{haml/templates → templates}/_av_partial_2.haml +1 -1
  69. data/test/{haml/templates → templates}/_av_partial_2_ugly.haml +1 -1
  70. data/test/{haml/templates → templates}/_layout.erb +0 -0
  71. data/test/{haml/templates → templates}/_layout_for_partial.haml +0 -0
  72. data/test/{haml/templates → templates}/_partial.haml +0 -0
  73. data/test/{haml/templates → templates}/_text_area.haml +0 -0
  74. data/test/{haml/templates → templates}/action_view.haml +1 -1
  75. data/test/{haml/templates → templates}/action_view_ugly.haml +1 -1
  76. data/test/{haml/templates → templates}/breakage.haml +0 -0
  77. data/test/{haml/templates → templates}/content_for_layout.haml +0 -0
  78. data/test/{haml/templates → templates}/eval_suppressed.haml +0 -0
  79. data/test/{haml/templates → templates}/helpers.haml +0 -0
  80. data/test/{haml/templates → templates}/helpful.haml +0 -0
  81. data/test/{haml/templates → templates}/just_stuff.haml +0 -0
  82. data/test/{haml/templates → templates}/list.haml +0 -0
  83. data/test/{haml/templates → templates}/nuke_inner_whitespace.haml +0 -0
  84. data/test/{haml/templates → templates}/nuke_outer_whitespace.haml +0 -0
  85. data/test/{haml/templates → templates}/original_engine.haml +0 -0
  86. data/test/templates/partial_layout.haml +3 -0
  87. data/test/{haml/templates → templates}/partialize.haml +0 -0
  88. data/test/{haml/templates → templates}/partials.haml +0 -0
  89. data/test/{haml/templates → templates}/render_layout.haml +0 -0
  90. data/test/{haml/templates → templates}/silent_script.haml +2 -2
  91. data/test/{haml/templates → templates}/standard.haml +0 -0
  92. data/test/{haml/templates → templates}/standard_ugly.haml +0 -0
  93. data/test/{haml/templates → templates}/tag_parsing.haml +0 -0
  94. data/test/{haml/templates → templates}/very_basic.haml +0 -0
  95. data/test/{haml/templates → templates}/whitespace_handling.haml +0 -0
  96. data/test/test_helper.rb +42 -34
  97. data/test/util_test.rb +80 -0
  98. metadata +259 -427
  99. data/CONTRIBUTING +0 -3
  100. data/REVISION +0 -1
  101. data/VERSION +0 -1
  102. data/VERSION_NAME +0 -1
  103. data/extra/update_watch.rb +0 -13
  104. data/lib/haml/root.rb +0 -7
  105. data/lib/haml/shared.rb +0 -78
  106. data/lib/haml/template/patch.rb +0 -58
  107. data/lib/sass.rb +0 -8
  108. data/lib/sass/plugin.rb +0 -10
  109. data/lib/sass/rails2_shim.rb +0 -9
  110. data/lib/sass/rails3_shim.rb +0 -16
  111. data/test/benchmark.rb +0 -91
  112. data/test/gemfiles/Gemfile.rails-2.0.x +0 -8
  113. data/test/gemfiles/Gemfile.rails-2.0.x.lock +0 -38
  114. data/test/gemfiles/Gemfile.rails-2.1.x +0 -8
  115. data/test/gemfiles/Gemfile.rails-2.1.x.lock +0 -38
  116. data/test/gemfiles/Gemfile.rails-2.2.x +0 -8
  117. data/test/gemfiles/Gemfile.rails-2.2.x.lock +0 -38
  118. data/test/gemfiles/Gemfile.rails-2.3.x +0 -8
  119. data/test/gemfiles/Gemfile.rails-2.3.x.lock +0 -40
  120. data/test/gemfiles/Gemfile.rails-3.0.x.lock +0 -85
  121. data/test/gemfiles/Gemfile.rails-3.1.x.lock +0 -98
  122. data/test/gemfiles/Gemfile.rails-xss-2.3.x +0 -9
  123. data/test/gemfiles/Gemfile.rails-xss-2.3.x.lock +0 -42
  124. data/test/haml/results/filters.xhtml +0 -62
  125. data/test/haml/spec/lua_haml_spec.lua +0 -30
  126. data/test/haml/spec/ruby_haml_test.rb +0 -19
  127. data/test/haml/spec_test.rb +0 -44
  128. data/test/haml/templates/filters.haml +0 -66
  129. data/test/haml/templates/partial_layout.haml +0 -10
  130. data/test/haml/util_test.rb +0 -300
  131. data/test/linked_rails.rb +0 -42
  132. data/vendor/sass/CONTRIBUTING +0 -3
  133. data/vendor/sass/MIT-LICENSE +0 -20
  134. data/vendor/sass/README.md +0 -201
  135. data/vendor/sass/Rakefile +0 -339
  136. data/vendor/sass/TODO +0 -39
  137. data/vendor/sass/VERSION +0 -1
  138. data/vendor/sass/VERSION_NAME +0 -1
  139. data/vendor/sass/bin/sass +0 -8
  140. data/vendor/sass/bin/sass-convert +0 -7
  141. data/vendor/sass/bin/scss +0 -8
  142. data/vendor/sass/doc-src/FAQ.md +0 -35
  143. data/vendor/sass/doc-src/INDENTED_SYNTAX.md +0 -210
  144. data/vendor/sass/doc-src/SASS_CHANGELOG.md +0 -2327
  145. data/vendor/sass/doc-src/SASS_REFERENCE.md +0 -1965
  146. data/vendor/sass/doc-src/SCSS_FOR_SASS_USERS.md +0 -155
  147. data/vendor/sass/ext/extconf.rb +0 -10
  148. data/vendor/sass/extra/update_watch.rb +0 -13
  149. data/vendor/sass/init.rb +0 -18
  150. data/vendor/sass/lib/sass.rb +0 -73
  151. data/vendor/sass/lib/sass/cache_stores.rb +0 -15
  152. data/vendor/sass/lib/sass/cache_stores/base.rb +0 -86
  153. data/vendor/sass/lib/sass/cache_stores/chain.rb +0 -33
  154. data/vendor/sass/lib/sass/cache_stores/filesystem.rb +0 -60
  155. data/vendor/sass/lib/sass/cache_stores/memory.rb +0 -47
  156. data/vendor/sass/lib/sass/cache_stores/null.rb +0 -25
  157. data/vendor/sass/lib/sass/callbacks.rb +0 -66
  158. data/vendor/sass/lib/sass/css.rb +0 -295
  159. data/vendor/sass/lib/sass/engine.rb +0 -878
  160. data/vendor/sass/lib/sass/environment.rb +0 -166
  161. data/vendor/sass/lib/sass/error.rb +0 -201
  162. data/vendor/sass/lib/sass/exec.rb +0 -672
  163. data/vendor/sass/lib/sass/importers.rb +0 -22
  164. data/vendor/sass/lib/sass/importers/base.rb +0 -139
  165. data/vendor/sass/lib/sass/importers/filesystem.rb +0 -149
  166. data/vendor/sass/lib/sass/less.rb +0 -382
  167. data/vendor/sass/lib/sass/logger.rb +0 -15
  168. data/vendor/sass/lib/sass/logger/base.rb +0 -32
  169. data/vendor/sass/lib/sass/logger/log_level.rb +0 -49
  170. data/vendor/sass/lib/sass/plugin.rb +0 -132
  171. data/vendor/sass/lib/sass/plugin/compiler.rb +0 -383
  172. data/vendor/sass/lib/sass/plugin/configuration.rb +0 -123
  173. data/vendor/sass/lib/sass/plugin/generic.rb +0 -15
  174. data/vendor/sass/lib/sass/plugin/merb.rb +0 -48
  175. data/vendor/sass/lib/sass/plugin/rack.rb +0 -60
  176. data/vendor/sass/lib/sass/plugin/rails.rb +0 -47
  177. data/vendor/sass/lib/sass/plugin/staleness_checker.rb +0 -173
  178. data/vendor/sass/lib/sass/railtie.rb +0 -9
  179. data/vendor/sass/lib/sass/repl.rb +0 -58
  180. data/vendor/sass/lib/sass/root.rb +0 -7
  181. data/vendor/sass/lib/sass/script.rb +0 -40
  182. data/vendor/sass/lib/sass/script/bool.rb +0 -18
  183. data/vendor/sass/lib/sass/script/color.rb +0 -480
  184. data/vendor/sass/lib/sass/script/css_lexer.rb +0 -29
  185. data/vendor/sass/lib/sass/script/css_parser.rb +0 -31
  186. data/vendor/sass/lib/sass/script/funcall.rb +0 -175
  187. data/vendor/sass/lib/sass/script/functions.rb +0 -1386
  188. data/vendor/sass/lib/sass/script/interpolation.rb +0 -79
  189. data/vendor/sass/lib/sass/script/lexer.rb +0 -339
  190. data/vendor/sass/lib/sass/script/list.rb +0 -83
  191. data/vendor/sass/lib/sass/script/literal.rb +0 -250
  192. data/vendor/sass/lib/sass/script/node.rb +0 -99
  193. data/vendor/sass/lib/sass/script/number.rb +0 -452
  194. data/vendor/sass/lib/sass/script/operation.rb +0 -99
  195. data/vendor/sass/lib/sass/script/parser.rb +0 -474
  196. data/vendor/sass/lib/sass/script/string.rb +0 -51
  197. data/vendor/sass/lib/sass/script/string_interpolation.rb +0 -103
  198. data/vendor/sass/lib/sass/script/unary_operation.rb +0 -64
  199. data/vendor/sass/lib/sass/script/variable.rb +0 -59
  200. data/vendor/sass/lib/sass/scss.rb +0 -17
  201. data/vendor/sass/lib/sass/scss/css_parser.rb +0 -46
  202. data/vendor/sass/lib/sass/scss/parser.rb +0 -960
  203. data/vendor/sass/lib/sass/scss/rx.rb +0 -128
  204. data/vendor/sass/lib/sass/scss/sass_parser.rb +0 -11
  205. data/vendor/sass/lib/sass/scss/script_lexer.rb +0 -15
  206. data/vendor/sass/lib/sass/scss/script_parser.rb +0 -25
  207. data/vendor/sass/lib/sass/scss/static_parser.rb +0 -40
  208. data/vendor/sass/lib/sass/selector.rb +0 -361
  209. data/vendor/sass/lib/sass/selector/abstract_sequence.rb +0 -62
  210. data/vendor/sass/lib/sass/selector/comma_sequence.rb +0 -81
  211. data/vendor/sass/lib/sass/selector/sequence.rb +0 -233
  212. data/vendor/sass/lib/sass/selector/simple.rb +0 -113
  213. data/vendor/sass/lib/sass/selector/simple_sequence.rb +0 -134
  214. data/vendor/sass/lib/sass/shared.rb +0 -78
  215. data/vendor/sass/lib/sass/tree/charset_node.rb +0 -22
  216. data/vendor/sass/lib/sass/tree/comment_node.rb +0 -90
  217. data/vendor/sass/lib/sass/tree/debug_node.rb +0 -18
  218. data/vendor/sass/lib/sass/tree/directive_node.rb +0 -23
  219. data/vendor/sass/lib/sass/tree/each_node.rb +0 -24
  220. data/vendor/sass/lib/sass/tree/extend_node.rb +0 -29
  221. data/vendor/sass/lib/sass/tree/for_node.rb +0 -36
  222. data/vendor/sass/lib/sass/tree/function_node.rb +0 -27
  223. data/vendor/sass/lib/sass/tree/if_node.rb +0 -52
  224. data/vendor/sass/lib/sass/tree/import_node.rb +0 -68
  225. data/vendor/sass/lib/sass/tree/media_node.rb +0 -32
  226. data/vendor/sass/lib/sass/tree/mixin_def_node.rb +0 -27
  227. data/vendor/sass/lib/sass/tree/mixin_node.rb +0 -32
  228. data/vendor/sass/lib/sass/tree/node.rb +0 -201
  229. data/vendor/sass/lib/sass/tree/prop_node.rb +0 -148
  230. data/vendor/sass/lib/sass/tree/return_node.rb +0 -18
  231. data/vendor/sass/lib/sass/tree/root_node.rb +0 -28
  232. data/vendor/sass/lib/sass/tree/rule_node.rb +0 -136
  233. data/vendor/sass/lib/sass/tree/variable_node.rb +0 -30
  234. data/vendor/sass/lib/sass/tree/visitors/base.rb +0 -75
  235. data/vendor/sass/lib/sass/tree/visitors/check_nesting.rb +0 -133
  236. data/vendor/sass/lib/sass/tree/visitors/convert.rb +0 -260
  237. data/vendor/sass/lib/sass/tree/visitors/cssize.rb +0 -175
  238. data/vendor/sass/lib/sass/tree/visitors/deep_copy.rb +0 -87
  239. data/vendor/sass/lib/sass/tree/visitors/perform.rb +0 -332
  240. data/vendor/sass/lib/sass/tree/visitors/set_options.rb +0 -97
  241. data/vendor/sass/lib/sass/tree/visitors/to_css.rb +0 -210
  242. data/vendor/sass/lib/sass/tree/warn_node.rb +0 -18
  243. data/vendor/sass/lib/sass/tree/while_node.rb +0 -18
  244. data/vendor/sass/lib/sass/util.rb +0 -721
  245. data/vendor/sass/lib/sass/util/subset_map.rb +0 -101
  246. data/vendor/sass/lib/sass/version.rb +0 -112
  247. data/vendor/sass/rails/init.rb +0 -1
  248. data/vendor/sass/sass.gemspec +0 -33
  249. data/vendor/sass/test/Gemfile +0 -4
  250. data/vendor/sass/test/Gemfile.lock +0 -19
  251. data/vendor/sass/test/sass/cache_test.rb +0 -89
  252. data/vendor/sass/test/sass/callbacks_test.rb +0 -61
  253. data/vendor/sass/test/sass/conversion_test.rb +0 -1199
  254. data/vendor/sass/test/sass/css2sass_test.rb +0 -373
  255. data/vendor/sass/test/sass/data/hsl-rgb.txt +0 -319
  256. data/vendor/sass/test/sass/engine_test.rb +0 -2567
  257. data/vendor/sass/test/sass/extend_test.rb +0 -1348
  258. data/vendor/sass/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
  259. data/vendor/sass/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
  260. data/vendor/sass/test/sass/functions_test.rb +0 -1038
  261. data/vendor/sass/test/sass/importer_test.rb +0 -192
  262. data/vendor/sass/test/sass/less_conversion_test.rb +0 -653
  263. data/vendor/sass/test/sass/logger_test.rb +0 -58
  264. data/vendor/sass/test/sass/mock_importer.rb +0 -49
  265. data/vendor/sass/test/sass/more_results/more1.css +0 -9
  266. data/vendor/sass/test/sass/more_results/more1_with_line_comments.css +0 -26
  267. data/vendor/sass/test/sass/more_results/more_import.css +0 -29
  268. data/vendor/sass/test/sass/more_templates/_more_partial.sass +0 -2
  269. data/vendor/sass/test/sass/more_templates/more1.sass +0 -23
  270. data/vendor/sass/test/sass/more_templates/more_import.sass +0 -11
  271. data/vendor/sass/test/sass/plugin_test.rb +0 -472
  272. data/vendor/sass/test/sass/results/alt.css +0 -4
  273. data/vendor/sass/test/sass/results/basic.css +0 -9
  274. data/vendor/sass/test/sass/results/compact.css +0 -5
  275. data/vendor/sass/test/sass/results/complex.css +0 -86
  276. data/vendor/sass/test/sass/results/compressed.css +0 -1
  277. data/vendor/sass/test/sass/results/expanded.css +0 -19
  278. data/vendor/sass/test/sass/results/if.css +0 -3
  279. data/vendor/sass/test/sass/results/import.css +0 -31
  280. data/vendor/sass/test/sass/results/import_charset.css +0 -4
  281. data/vendor/sass/test/sass/results/import_charset_1_8.css +0 -4
  282. data/vendor/sass/test/sass/results/import_charset_ibm866.css +0 -4
  283. data/vendor/sass/test/sass/results/line_numbers.css +0 -49
  284. data/vendor/sass/test/sass/results/mixins.css +0 -95
  285. data/vendor/sass/test/sass/results/multiline.css +0 -24
  286. data/vendor/sass/test/sass/results/nested.css +0 -22
  287. data/vendor/sass/test/sass/results/options.css +0 -1
  288. data/vendor/sass/test/sass/results/parent_ref.css +0 -13
  289. data/vendor/sass/test/sass/results/script.css +0 -16
  290. data/vendor/sass/test/sass/results/scss_import.css +0 -31
  291. data/vendor/sass/test/sass/results/scss_importee.css +0 -2
  292. data/vendor/sass/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
  293. data/vendor/sass/test/sass/results/subdir/subdir.css +0 -3
  294. data/vendor/sass/test/sass/results/units.css +0 -11
  295. data/vendor/sass/test/sass/results/warn.css +0 -0
  296. data/vendor/sass/test/sass/results/warn_imported.css +0 -0
  297. data/vendor/sass/test/sass/script_conversion_test.rb +0 -285
  298. data/vendor/sass/test/sass/script_test.rb +0 -514
  299. data/vendor/sass/test/sass/scss/css_test.rb +0 -922
  300. data/vendor/sass/test/sass/scss/rx_test.rb +0 -156
  301. data/vendor/sass/test/sass/scss/scss_test.rb +0 -1273
  302. data/vendor/sass/test/sass/scss/test_helper.rb +0 -37
  303. data/vendor/sass/test/sass/templates/_imported_charset_ibm866.sass +0 -4
  304. data/vendor/sass/test/sass/templates/_imported_charset_utf8.sass +0 -4
  305. data/vendor/sass/test/sass/templates/_partial.sass +0 -2
  306. data/vendor/sass/test/sass/templates/alt.sass +0 -16
  307. data/vendor/sass/test/sass/templates/basic.sass +0 -23
  308. data/vendor/sass/test/sass/templates/bork1.sass +0 -2
  309. data/vendor/sass/test/sass/templates/bork2.sass +0 -2
  310. data/vendor/sass/test/sass/templates/bork3.sass +0 -2
  311. data/vendor/sass/test/sass/templates/bork4.sass +0 -2
  312. data/vendor/sass/test/sass/templates/bork5.sass +0 -3
  313. data/vendor/sass/test/sass/templates/compact.sass +0 -17
  314. data/vendor/sass/test/sass/templates/complex.sass +0 -305
  315. data/vendor/sass/test/sass/templates/compressed.sass +0 -15
  316. data/vendor/sass/test/sass/templates/expanded.sass +0 -17
  317. data/vendor/sass/test/sass/templates/if.sass +0 -11
  318. data/vendor/sass/test/sass/templates/import.sass +0 -12
  319. data/vendor/sass/test/sass/templates/import_charset.sass +0 -7
  320. data/vendor/sass/test/sass/templates/import_charset_1_8.sass +0 -4
  321. data/vendor/sass/test/sass/templates/import_charset_ibm866.sass +0 -9
  322. data/vendor/sass/test/sass/templates/importee.less +0 -2
  323. data/vendor/sass/test/sass/templates/importee.sass +0 -19
  324. data/vendor/sass/test/sass/templates/line_numbers.sass +0 -13
  325. data/vendor/sass/test/sass/templates/mixin_bork.sass +0 -5
  326. data/vendor/sass/test/sass/templates/mixins.sass +0 -76
  327. data/vendor/sass/test/sass/templates/multiline.sass +0 -20
  328. data/vendor/sass/test/sass/templates/nested.sass +0 -25
  329. data/vendor/sass/test/sass/templates/nested_bork1.sass +0 -2
  330. data/vendor/sass/test/sass/templates/nested_bork2.sass +0 -2
  331. data/vendor/sass/test/sass/templates/nested_bork3.sass +0 -2
  332. data/vendor/sass/test/sass/templates/nested_bork4.sass +0 -2
  333. data/vendor/sass/test/sass/templates/nested_bork5.sass +0 -2
  334. data/vendor/sass/test/sass/templates/nested_import.sass +0 -2
  335. data/vendor/sass/test/sass/templates/nested_mixin_bork.sass +0 -6
  336. data/vendor/sass/test/sass/templates/options.sass +0 -2
  337. data/vendor/sass/test/sass/templates/parent_ref.sass +0 -25
  338. data/vendor/sass/test/sass/templates/script.sass +0 -101
  339. data/vendor/sass/test/sass/templates/scss_import.scss +0 -11
  340. data/vendor/sass/test/sass/templates/scss_importee.scss +0 -1
  341. data/vendor/sass/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
  342. data/vendor/sass/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
  343. data/vendor/sass/test/sass/templates/subdir/subdir.sass +0 -6
  344. data/vendor/sass/test/sass/templates/units.sass +0 -11
  345. data/vendor/sass/test/sass/templates/warn.sass +0 -3
  346. data/vendor/sass/test/sass/templates/warn_imported.sass +0 -4
  347. data/vendor/sass/test/sass/test_helper.rb +0 -8
  348. data/vendor/sass/test/sass/util/subset_map_test.rb +0 -91
  349. data/vendor/sass/test/sass/util_test.rb +0 -266
  350. data/vendor/sass/test/test_helper.rb +0 -69
  351. data/vendor/sass/vendor/fssm/Gemfile +0 -3
  352. data/vendor/sass/vendor/fssm/LICENSE +0 -20
  353. data/vendor/sass/vendor/fssm/README.markdown +0 -83
  354. data/vendor/sass/vendor/fssm/Rakefile +0 -11
  355. data/vendor/sass/vendor/fssm/example.rb +0 -12
  356. data/vendor/sass/vendor/fssm/fssm.gemspec +0 -24
  357. data/vendor/sass/vendor/fssm/lib/fssm.rb +0 -37
  358. data/vendor/sass/vendor/fssm/lib/fssm/backends/fsevents.rb +0 -36
  359. data/vendor/sass/vendor/fssm/lib/fssm/backends/inotify.rb +0 -26
  360. data/vendor/sass/vendor/fssm/lib/fssm/backends/polling.rb +0 -25
  361. data/vendor/sass/vendor/fssm/lib/fssm/backends/rbfsevent.rb +0 -42
  362. data/vendor/sass/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +0 -131
  363. data/vendor/sass/vendor/fssm/lib/fssm/monitor.rb +0 -36
  364. data/vendor/sass/vendor/fssm/lib/fssm/path.rb +0 -94
  365. data/vendor/sass/vendor/fssm/lib/fssm/pathname.rb +0 -36
  366. data/vendor/sass/vendor/fssm/lib/fssm/state/directory.rb +0 -75
  367. data/vendor/sass/vendor/fssm/lib/fssm/state/file.rb +0 -24
  368. data/vendor/sass/vendor/fssm/lib/fssm/support.rb +0 -92
  369. data/vendor/sass/vendor/fssm/lib/fssm/tree.rb +0 -176
  370. data/vendor/sass/vendor/fssm/lib/fssm/version.rb +0 -3
  371. data/vendor/sass/vendor/fssm/profile/prof-cache.rb +0 -40
  372. data/vendor/sass/vendor/fssm/profile/prof-fssm-pathname.html +0 -1231
  373. data/vendor/sass/vendor/fssm/profile/prof-pathname-rubinius.rb +0 -35
  374. data/vendor/sass/vendor/fssm/profile/prof-pathname.rb +0 -68
  375. data/vendor/sass/vendor/fssm/profile/prof-plain-pathname.html +0 -988
  376. data/vendor/sass/vendor/fssm/profile/prof.html +0 -2379
  377. data/vendor/sass/vendor/fssm/spec/count_down_latch.rb +0 -151
  378. data/vendor/sass/vendor/fssm/spec/monitor_spec.rb +0 -202
  379. data/vendor/sass/vendor/fssm/spec/path_spec.rb +0 -96
  380. data/vendor/sass/vendor/fssm/spec/root/duck/quack.txt +0 -0
  381. data/vendor/sass/vendor/fssm/spec/root/file.css +0 -0
  382. data/vendor/sass/vendor/fssm/spec/root/file.rb +0 -0
  383. data/vendor/sass/vendor/fssm/spec/root/file.yml +0 -0
  384. data/vendor/sass/vendor/fssm/spec/root/moo/cow.txt +0 -0
  385. data/vendor/sass/vendor/fssm/spec/spec_helper.rb +0 -14
  386. data/vendor/sass/yard/callbacks.rb +0 -29
  387. data/vendor/sass/yard/default/fulldoc/html/css/common.sass +0 -26
  388. data/vendor/sass/yard/default/layout/html/footer.erb +0 -12
  389. data/vendor/sass/yard/inherited_hash.rb +0 -41
data/FAQ.md ADDED
@@ -0,0 +1,157 @@
1
+ # Frequently Asked Questions
2
+
3
+ ## Haml
4
+
5
+ ### Why is my markup indented properly in development mode, but not in production?
6
+ {#q-indentation-in-production}
7
+
8
+ To improve performance, Haml defaults to {file:HAML_REFERENCE.md#ugly-option "ugly" mode} in Rails
9
+ apps running in production.
10
+
11
+
12
+ ### How do I put a punctuation mark after an element, like "`I like <strong>cake</strong>!`"?
13
+ {#q-punctuation}
14
+
15
+ Expressing the structure of a document
16
+ and expressing inline formatting are two very different problems.
17
+ Haml is mostly designed for structure,
18
+ so the best way to deal with formatting is to leave it to other languages
19
+ that are designed for it.
20
+ You could use Textile:
21
+
22
+ %p
23
+ :textile
24
+ I like *cake*!
25
+
26
+ or Markdown:
27
+
28
+ %p
29
+ :markdown
30
+ I like **cake**!
31
+
32
+ or plain old XHTML:
33
+
34
+ %p I like <strong>cake</strong>!
35
+
36
+ If you're inserting something that's generated by a helper, like a link,
37
+ then it's even easier:
38
+
39
+ %p== I like #{link_to 'chocolate', 'http://franschocolates.com'}!
40
+
41
+ ### How do I stop Haml from indenting the contents of my `pre` and `textarea` tags?
42
+ {#q-preserve}
43
+
44
+ Because Haml automatically indents the HTML source code,
45
+ the contents of whitespace-sensitive tags like `pre` and `textarea`
46
+ can get screwed up.
47
+ The solution is to replace the newlines inside these tags
48
+ with HTML newline entities (`&#x000A;`),
49
+ which Haml does using the {Haml::Helpers#preserve} and {Haml::Helpers#find_and_preserve} helpers.
50
+
51
+ Normally, Haml will do this for you automatically
52
+ when you're using a tag that needs it
53
+ (this can be customized using the {file:HAML_REFERENCE.md#preserve-option `:preserve`} option.
54
+ For example,
55
+
56
+ %p
57
+ %textarea= "Foo\nBar"
58
+
59
+ will be compiled to
60
+
61
+ <p>
62
+ <textarea>Foo&#x000A;Bar</textarea>
63
+ </p>
64
+
65
+ However, if a helper is generating the tag,
66
+ Haml can't detect that and so you'll have to call {Haml::Helpers#find_and_preserve} yourself.
67
+ You can also use `~`, which is the same as `=`
68
+ except that it automatically runs `find_and_preserve` on its input.
69
+ For example:
70
+
71
+ %p= find_and_preserve "<textarea>Foo\nBar</textarea>"
72
+
73
+ is the same as
74
+
75
+ %p~ "<textarea>Foo\nBar</textarea>"
76
+
77
+ and renders
78
+
79
+ <p><textarea>Foo&#x000A;Bar</textarea></p>
80
+
81
+ ### How do I make my long lines of Ruby code look nicer in my Haml document?
82
+ {#q-multiline}
83
+
84
+ Put them in a helper or your model.
85
+
86
+ Haml purposefully makes it annoying to put lots of Ruby code into your templates,
87
+ because lots of code doesn't belong in the view.
88
+ If you take that huge `link_to_remote` call
89
+ and move it to a `update_sidebar_link` helper,
90
+ it'll make your view both easier to read and more semantic.
91
+
92
+ If you absolutely must put lots of code in your template,
93
+ Haml offers a somewhat awkward multiline-continuation tool.
94
+ Put a `|` (pipe character) at the end of each line you want to be merged into one
95
+ (including the last line!).
96
+ For example:
97
+
98
+ %p= @this.is(way.too.much). |
99
+ code("and I should"). |
100
+ really_move.it.into( |
101
+ :a => @helper) |
102
+
103
+ Note that sometimes it is valid to include lots of Ruby in a template
104
+ when that Ruby is a helper call that passes in a lot of template information.
105
+ Thus when a function has lots of arguments,
106
+ it's possible to wrap it across multiple lines
107
+ as long as each line ends in a comma.
108
+ For example:
109
+
110
+ = link_to_remote "Add to cart",
111
+ :url => { :action => "add", :id => product.id },
112
+ :update => { :success => "cart", :failure => "error" }
113
+
114
+ ### `form_for` is printing the form tag twice!
115
+
116
+ Make sure you're calling it with `-`, not `=`.
117
+ Just like in ERB, you have to do
118
+
119
+ <% form_for stuff do %>
120
+ ...
121
+ <% end %>
122
+
123
+ in Haml, you have to do
124
+
125
+ - form_for stuff do
126
+ ...
127
+
128
+ ### I have Haml installed. Why is Rails (only looking for `.html.erb` files | rendering Haml files as plain text | rendering Haml files as blank pages)?
129
+ {#q-blank-page}
130
+
131
+ There are several reasons these things might be happening.
132
+ First of all, make sure that Haml really is installed;
133
+ either you've loaded the gem (via `config.gem` in Rails 2.3 or in the Gemfile in Rails 3),
134
+ or `vendor/plugins/haml` exists and contains files.
135
+ Then try restarting Mongrel or WEBrick or whatever you might be using.
136
+
137
+ Finally, if none of these work,
138
+ chances are you've got some localization plugin like Globalize installed.
139
+ Such plugins often don't play nicely with Haml.
140
+ Luckily, there's usually an easy fix.
141
+ For Globalize, just edit `globalize/lib/globalize/rails/action_view.rb`
142
+ and change
143
+
144
+ @@re_extension = /\.(rjs|rhtml|rxml)$/
145
+
146
+ to
147
+
148
+ @@re_extension = /\.(rjs|rhtml|rxml|erb|builder|haml)$/
149
+
150
+ For other plugins, a little searching will probably turn up a way to fix them as well.
151
+
152
+ ## You still haven't answered my question!
153
+
154
+ Sorry! Try looking at the [Haml](http://haml.info/docs/yardoc/HAML_REFERENCE.md.html) reference,
155
+ If you can't find an answer there,
156
+ feel free to ask in `#haml` on irc.freenode.net
157
+ or send an email to the [mailing list](http://groups.google.com/group/haml).
data/README.md CHANGED
@@ -1,59 +1,55 @@
1
1
  # Haml
2
2
 
3
- Haml is a templating engine for HTML.
4
- It's are designed to make it both easier and more pleasant
5
- to write HTML documents,
6
- by eliminating redundancy,
7
- reflecting the underlying structure that the document represents,
8
- and providing elegant, easily understandable, and powerful syntax.
3
+ [![Build Status](https://secure.travis-ci.org/haml/haml.png?branch=master)](http://travis-ci.org/haml/haml)
9
4
 
10
- ## Using
5
+ Haml is a templating engine for HTML. It's designed to make it both easier and
6
+ more pleasant to write HTML documents, by eliminating redundancy, reflecting the
7
+ underlying structure that the document represents, and providing an elegant syntax
8
+ that's both powerful and easy to understand.
11
9
 
12
- Haml can be used from the command line
13
- or as part of a Ruby web framework.
14
- The first step is to install the gem:
10
+ ## Basic Usage
11
+
12
+ Haml can be used from the command line or as part of a Ruby web framework. The
13
+ first step is to install the gem:
15
14
 
16
15
  gem install haml
17
16
 
18
- After you convert some HTML to Haml, you can run
17
+ After you write some Haml, you can run
19
18
 
20
19
  haml document.haml
21
20
 
22
- to compile them.
23
- For more information on these commands, check out
21
+ to compile it to HTML. For more information on these commands, check out
24
22
 
25
23
  haml --help
26
24
 
27
- To install Haml in Rails 2,
28
- just add `config.gem "haml"` to `config/environment.rb`.
29
- In Rails 3, add `gem "haml"` to your Gemfile instead.
30
- and both Haml and Sass will be installed.
31
- Views with the `.html.haml` extension will automatically use Haml.
25
+ To use Haml programatically, check out the [YARD
26
+ documentation](http://haml.info/docs/yardoc/).
27
+
28
+ ## Using Haml with Rails
29
+
30
+ To use Haml with Rails, simply add Haml to your Gemfile and run `bundle`.
32
31
 
33
- To use Haml programatically,
34
- check out the [YARD documentation](http://haml-lang.com/docs/yardoc/).
32
+ If you'd like to replace Rails's Erb-based generators with Haml, add
33
+ [haml-rails](https://github.com/indirect/haml-rails) to your Gemfile as well.
35
34
 
36
35
  ## Formatting
37
36
 
38
- The most basic element of Haml
39
- is a shorthand for creating HTML:
37
+ The most basic element of Haml is a shorthand for creating HTML:
40
38
 
41
39
  %tagname{:attr1 => 'value1', :attr2 => 'value2'} Contents
42
40
 
43
- No end-tag is needed; Haml handles that automatically.
44
- If you prefer HTML-style attributes, you can also use:
41
+ No end-tag is needed; Haml handles that automatically. If you prefer HTML-style
42
+ attributes, you can also use:
45
43
 
46
44
  %tagname(attr1='value1' attr2='value2') Contents
47
45
 
48
- Adding `class` and `id` attributes is even easier.
49
- Haml uses the same syntax as the CSS that styles the document:
46
+ Adding `class` and `id` attributes is even easier. Haml uses the same syntax as
47
+ the CSS that styles the document:
50
48
 
51
49
  %tagname#id.class
52
50
 
53
- In fact, when you're using the `<div>` tag,
54
- it becomes _even easier_.
55
- Because `<div>` is such a common element,
56
- a tag without a name defaults to a div. So
51
+ In fact, when you're using the `<div>` tag, it becomes _even easier_. Because
52
+ `<div>` is such a common element, a tag without a name defaults to a div. So
57
53
 
58
54
  #foo Hello!
59
55
 
@@ -61,11 +57,9 @@ becomes
61
57
 
62
58
  <div id='foo'>Hello!</div>
63
59
 
64
- Haml uses indentation
65
- to bring the individual elements to represent the HTML structure.
66
- A tag's children are indented beneath than the parent tag.
67
- Again, a closing tag is automatically added.
68
- For example:
60
+ Haml uses indentation to bring the individual elements to represent the HTML
61
+ structure. A tag's children are indented beneath than the parent tag. Again, a
62
+ closing tag is automatically added. For example:
69
63
 
70
64
  %ul
71
65
  %li Salt
@@ -84,11 +78,9 @@ You can also put plain text as a child of an element:
84
78
  Hello,
85
79
  World!
86
80
 
87
- It's also possible to embed Ruby code into Haml documents.
88
- An equals sign, `=`, will output the result of the code.
89
- A hyphen, `-`, will run the code but not output the result.
90
- You can even use control statements
91
- like `if` and `while`:
81
+ It's also possible to embed Ruby code into Haml documents. An equals sign, `=`,
82
+ will output the result of the code. A hyphen, `-`, will run the code but not
83
+ output the result. You can even use control statements like `if` and `while`:
92
84
 
93
85
  %p
94
86
  Date/Time:
@@ -97,37 +89,82 @@ like `if` and `while`:
97
89
  - if now > DateTime.parse("December 31, 2006")
98
90
  = "Happy new " + "year!"
99
91
 
100
- Haml provides far more tools than those presented here.
101
- Check out the [reference documentation](http://beta.haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html)
92
+ Haml provides far more tools than those presented here. Check out the [reference
93
+ documentation](http://haml.info/docs/yardoc/file.REFERENCE.html)
102
94
  for full details.
103
95
 
104
96
  ### Indentation
105
97
 
106
- Haml's indentation can be made up of one or more tabs or spaces.
107
- However, indentation must be consistent within a given document.
108
- Hard tabs and spaces can't be mixed,
109
- and the same number of tabs or spaces must be used throughout.
98
+ Haml's indentation can be made up of one or more tabs or spaces. However,
99
+ indentation must be consistent within a given document. Hard tabs and spaces
100
+ can't be mixed, and the same number of tabs or spaces must be used throughout.
101
+
102
+ ## Contributing
103
+
104
+ Contributions are welcomed, but before you get started please read the
105
+ [guidelines](http://haml.info/development.html#contributing).
106
+
107
+ After forking and then cloning the repo locally, install Bundler and then use it
108
+ to install the development gem dependecies:
109
+
110
+ gem install bundler
111
+ bundle install
112
+
113
+ Once this is complete, you should be able to run the test suite:
114
+
115
+ rake
116
+
117
+ You'll get a warning that you need to install haml-spec, so run this:
118
+
119
+ git submodule update --init
120
+
121
+ At this point `rake` should run without error or warning and you are ready to
122
+ start working on your patch!
123
+
124
+ Note that you can also run just one test out of the test suite if you're working
125
+ on a specific area:
126
+
127
+ ruby -Itest test/helper_test.rb -n test_buffer_access
128
+
129
+ Haml supports Ruby 1.8.7 and higher, so please make sure your changes run on
130
+ both 1.9 and 1.8.
110
131
 
111
132
  ## Authors
112
133
 
113
- Haml was created by [Hampton Catlin](http://hamptoncatlin.com)
114
- (hcatlin) and he is the author of the original implementation. However, Hampton
115
- doesn't even know his way around the code anymore and now occasionally consults
116
- on the language issues. Hampton lives in Jacksonville, Florida and is the lead
117
- mobile developer for Wikimedia.
134
+ Haml was created by [Hampton Catlin](http://hamptoncatlin.com), the author of
135
+ the original implementation. However, Hampton doesn't even know his way around
136
+ the code anymore and now just occasionally consults on the language issues.
118
137
 
119
- [Nathan Weizenbaum](http://nex-3.com) is the primary developer and architect of
120
- the "modern" Ruby implementation of Haml. His hard work has kept the project
121
- alive by endlessly answering forum posts, fixing bugs, refactoring, finding
122
- speed improvements, writing documentation, implementing new features, and
123
- getting Hampton coffee (a fitting task for a boy-genius). Nathan lives in
124
- Seattle, Washington and while not being a student at the University of
125
- Washington or working at an internship, he consults for Unspace Interactive.
138
+ [Nathan Weizenbaum](http://nex-3.com) was for many years the primary developer
139
+ and architect of the "modern" Ruby implementation of Haml. His hard work
140
+ endlessly answering forum posts, fixing bugs, refactoring, finding speed
141
+ improvements, writing documentation, and implementing new features is what has
142
+ kept the project alive.
126
143
 
127
- If you use this software, you must pay Hampton a compliment. And
128
- buy Nathan some jelly beans. Maybe pet a kitten. Yeah. Pet that kitty.
144
+ [Norman Clarke](http://github.com/norman), the author of Haml Spec and the Haml
145
+ implementation in Lua, took over as maintainer in April 2012.
129
146
 
130
- Some of the work on Haml was supported by Unspace Interactive.
147
+ ## License
148
+
149
+ Some of Nathan's work on Haml was supported by Unspace Interactive.
131
150
 
132
151
  Beyond that, the implementation is licensed under the MIT License.
133
- Okay, fine, I guess that means compliments aren't __required__.
152
+
153
+ Copyright (c) 2006-2009 Hampton Catlin and Nathan Weizenbaum
154
+
155
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
156
+ this software and associated documentation files (the "Software"), to deal in
157
+ the Software without restriction, including without limitation the rights to
158
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
159
+ the Software, and to permit persons to whom the Software is furnished to do so,
160
+ subject to the following conditions:
161
+
162
+ The above copyright notice and this permission notice shall be included in all
163
+ copies or substantial portions of the Software.
164
+
165
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
166
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
167
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
168
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
169
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
170
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,1404 @@
1
+ # Haml (XHTML Abstraction Markup Language)
2
+
3
+ Haml is a markup language
4
+ that's used to cleanly and simply describe the XHTML of any web document,
5
+ without the use of inline code.
6
+ Haml functions as a replacement
7
+ for inline page templating systems such as PHP, ERB, and ASP.
8
+ However, Haml avoids the need for explicitly coding XHTML into the template,
9
+ because it is actually an abstract description of the XHTML,
10
+ with some code to generate dynamic content.
11
+
12
+ ## Features
13
+
14
+ * Whitespace active
15
+ * Well-formatted markup
16
+ * DRY
17
+ * Follows CSS conventions
18
+ * Integrates Ruby code
19
+ * Implements Rails templates with the .haml extension
20
+
21
+ ## Using Haml
22
+
23
+ Haml can be used in three ways:
24
+ as a command-line tool,
25
+ as a plugin for Ruby on Rails,
26
+ and as a standalone Ruby module.
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
+
37
+ ### Rails/Merb Plugin {#plugin}
38
+
39
+ To enable Haml in Rails versions before Rails 3,
40
+ add the following line to `environment.rb`:
41
+
42
+ config.gem "haml"
43
+
44
+ For Rails 3, instead add the following line to the Gemfile:
45
+
46
+ gem "haml"
47
+
48
+ Once it's installed, all view files with the `".html.haml"` extension
49
+ will be compiled using Haml.
50
+ Haml is enabled by default in Merb.
51
+
52
+ You can access instance variables in Haml templates
53
+ the same way you do in ERB templates.
54
+ Helper methods are also available in Haml templates.
55
+ For example (this example uses Rails, but the principle for Merb is the same):
56
+
57
+ # file: app/controllers/movies_controller.rb
58
+
59
+ class MoviesController < ApplicationController
60
+ def index
61
+ @title = "Teen Wolf"
62
+ end
63
+ end
64
+
65
+ -# file: app/views/movies/index.haml
66
+
67
+ #content
68
+ .title
69
+ %h1= @title
70
+ = link_to 'Home', home_url
71
+
72
+ may be compiled to:
73
+
74
+ <div id='content'>
75
+ <div class='title'>
76
+ <h1>Teen Wolf</h1>
77
+ <a href='/'>Home</a>
78
+ </div>
79
+ </div>
80
+
81
+ #### Rails XSS Protection
82
+
83
+ Haml supports Rails' XSS protection scheme,
84
+ which was introduced in Rails 2.3.5+ and is enabled by default in 3.0.0+.
85
+ If it's enabled, Haml's [`:escape_html`](#escape_html-option)
86
+ option is set to `true` by default -
87
+ like in ERB, all strings printed to a Haml template are escaped by default.
88
+ Also like ERB, strings marked as HTML safe are not escaped.
89
+ Haml also has [its own syntax for printing a raw string to the template](#unescaping_html).
90
+
91
+ If the `:escape_html` option is set to false when XSS protection is enabled,
92
+ Haml doesn't escape Ruby strings by default.
93
+ However, if a string marked HTML-safe is passed to [Haml's escaping syntax](#escaping_html),
94
+ it won't be escaped.
95
+
96
+ Finally, all the {Haml::Helpers Haml helpers} that return strings
97
+ that are known to be HTML safe are marked as such.
98
+ In addition, string input is escaped unless it's HTML safe.
99
+
100
+ ### Ruby Module
101
+
102
+ Haml can also be used completely separately from Rails and ActionView.
103
+ To do this, install the gem with RubyGems:
104
+
105
+ gem install haml
106
+
107
+ You can then use it by including the "haml" gem in Ruby code,
108
+ and using {Haml::Engine} like so:
109
+
110
+ engine = Haml::Engine.new("%p Haml code!")
111
+ engine.render #=> "<p>Haml code!</p>\n"
112
+
113
+ ### Options
114
+
115
+ Options can be set by setting the {Haml::Template#options Haml::Template.options} hash
116
+ in `environment.rb` in Rails...
117
+
118
+ Haml::Template.options[:format] = :html5
119
+
120
+ ...or by setting the `Merb::Plugin.config[:haml]` hash in `init.rb` in Merb...
121
+
122
+ Merb::Plugin.config[:haml][:format] = :html5
123
+
124
+ ...or by passing an options hash to {Haml::Engine#initialize}.
125
+ Available options are:
126
+
127
+ {#format-option} `:format`
128
+ : Determines the output format. Normally the default is `:xhtml`,
129
+ although under Rails 3 it's `:html5`, since that's the Rails 3's default format.
130
+ Other options are `:html4` and `:html5`, which are
131
+ identical to `:xhtml` except there are no self-closing tags,
132
+ the XML prolog is ignored and correct DOCTYPEs are generated.
133
+ <br/><br/> <!-- There's no better way to do a paragraph break in a dl in Maruku -->
134
+ If the mime_type of the template being rendered is `text/xml` then
135
+ a format of `:xhtml` will be used even if the global output format
136
+ is set to `:html4` or `:html5`.
137
+
138
+ {#escape_html-option} `:escape_html`
139
+ : Sets whether or not to escape HTML-sensitive characters in script.
140
+ If this is true, `=` behaves like [`&=`](#escaping_html);
141
+ otherwise, it behaves like [`!=`](#unescaping_html).
142
+ Note that if this is set, `!=` should be used for yielding to subtemplates
143
+ and rendering partials.
144
+ See also [Escaping HTML](#escaping_html) and [Unescaping HTML](#unescaping_html)
145
+ Defaults to false.
146
+
147
+ {#escape_attrs-option} `:escape_attrs`
148
+ : Sets whether or not to escape HTML-sensitive characters in attributes.
149
+ If this is true, all HTML-sensitive characters in attributes are escaped.
150
+ If it's set to false, no HTML-sensitive characters in attributes are escaped.
151
+ If it's set to `:once`, existing HTML escape sequences are preserved,
152
+ but other HTML-sensitive characters are escaped.
153
+ Defaults to `:once`.
154
+
155
+ {#ugly-option} `:ugly`
156
+ : If set to `true`, Haml makes no attempt to properly
157
+ indent or format the HTML output.
158
+ This significantly improves rendering performance
159
+ but makes viewing the source unpleasant.
160
+ Defaults to `true` in Rails production mode, and `false`
161
+ everywhere else.
162
+
163
+ {#suppress_eval-option} `:suppress_eval`
164
+ : Whether or not attribute hashes and Ruby scripts
165
+ designated by `=` or `~` should be
166
+ evaluated. If this is `true`, said scripts are
167
+ rendered as empty strings. Defaults to `false`.
168
+
169
+ {#attr_wrapper-option} `:attr_wrapper`
170
+ : The character that should wrap element attributes.
171
+ This defaults to `'` (an apostrophe). Characters
172
+ of this type within the attributes will be escaped
173
+ (e.g. by replacing them with `&apos;`) if
174
+ the character is an apostrophe or a quotation mark.
175
+
176
+ {#hyphenate_data_attrs} `:hyphenate_data_attrs`
177
+ : If set to `true`, Haml will convert underscores to hyphens in all
178
+ [Custom Data Attributes](#html5_custom_data_attributes)
179
+ As of Haml 3.2, this defaults to `true`.
180
+
181
+ {#filename-option} `:filename`
182
+ : The name of the Haml file being parsed.
183
+ This is only used as information when exceptions are raised.
184
+ This is automatically assigned when working through ActionView,
185
+ so it's really only useful for the user to assign
186
+ when dealing with Haml programatically.
187
+
188
+ {#line-option} `:line`
189
+ : The line offset of the Haml template being parsed.
190
+ This is useful for inline templates,
191
+ similar to the last argument to `Kernel#eval`.
192
+
193
+ {#autoclose-option} `:autoclose`
194
+ : A list of tag names that should be automatically self-closed
195
+ if they have no content.
196
+ This can also contain regular expressions that match tag names
197
+ (or any object which responds to `#===`).
198
+ Defaults to `['meta', 'img', 'link', 'br', 'hr', 'input', 'area', 'param', 'col', 'base']`.
199
+
200
+ {#preserve-option} `:preserve`
201
+ : A list of tag names that should automatically have their newlines preserved
202
+ using the {Haml::Helpers#preserve} helper.
203
+ This means that any content given on the same line as the tag will be preserved.
204
+ For example, `%textarea= "Foo\nBar"` compiles to `<textarea>Foo&#x000A;Bar</textarea>`.
205
+ Defaults to `['textarea', 'pre']`.
206
+ See also [Whitespace Preservation](#whitespace_preservation).
207
+
208
+ {#encoding-option} `:encoding`
209
+ : The encoding to use for the HTML output.
210
+ Only available in Ruby 1.9 or higher.
211
+ This can be a string or an `Encoding` Object.
212
+ Note that Haml **does not** automatically re-encode Ruby values;
213
+ any strings coming from outside the application should be converted
214
+ before being passed into the Haml template.
215
+ Defaults to `Encoding.default_internal`; if that's not set,
216
+ defaults to the encoding of the Haml template;
217
+ if that's `us-ascii`, defaults to `"utf-8"`.
218
+ <br/><br/> <!-- There's no better way to do a paragraph break in a dl in Maruku -->
219
+ Many Ruby database drivers are not yet Ruby 1.9 compatible;
220
+ in particular, they return strings marked as ASCII-encoded
221
+ even when those strings contain non-ASCII characters (such as UTF-8).
222
+ **This will cause encoding errors** if the Haml encoding isn't set to `"ascii-8bit"`.
223
+ To solve this, either call `#force_encoding` on all the strings returned from the database,
224
+ set `:encoding` to `"ascii-8bit"`, or try to get the authors of the database drivers
225
+ to make them Ruby 1.9 compatible.
226
+
227
+ ### Encodings
228
+
229
+ When using Ruby 1.9 or later,
230
+ Haml supports the same sorts of encoding-declaration comments that Ruby does.
231
+ Although both Ruby and Haml support several different styles,
232
+ the easiest it just to add `-# coding: encoding-name`
233
+ at the beginning of the Haml template
234
+ (it must come before all other lines).
235
+ This will tell Haml that the template is encoded using the named encoding.
236
+
237
+ By default, the HTML generated by Haml has the same encoding as the Haml template.
238
+ However, if `Encoding.default_internal` is set, Haml will attempt to use that instead.
239
+ In addition, the [`:encoding` option](#encoding-option) can be used
240
+ to specify an output encoding manually.
241
+
242
+ Note that, like Ruby, Haml does not support templates encoded in UTF-16 or UTF-32,
243
+ since these encodings are not compatible with ASCII.
244
+ It is possible to use these as the output encoding, though.
245
+
246
+ ## Plain Text
247
+
248
+ A substantial portion of any HTML document is its content,
249
+ which is plain old text.
250
+ Any Haml line that's not interpreted as something else
251
+ is taken to be plain text, and passed through unmodified.
252
+ For example:
253
+
254
+ %gee
255
+ %whiz
256
+ Wow this is cool!
257
+
258
+ is compiled to:
259
+
260
+ <gee>
261
+ <whiz>
262
+ Wow this is cool!
263
+ </whiz>
264
+ </gee>
265
+
266
+ Note that HTML tags are passed through unmodified as well.
267
+ If you have some HTML you don't want to convert to Haml,
268
+ or you're converting a file line-by-line,
269
+ you can just include it as-is.
270
+ For example:
271
+
272
+ %p
273
+ <div id="blah">Blah!</div>
274
+
275
+ is compiled to:
276
+
277
+ <p>
278
+ <div id="blah">Blah!</div>
279
+ </p>
280
+
281
+ ### Escaping: `\`
282
+
283
+ The backslash character escapes the first character of a line,
284
+ allowing use of otherwise interpreted characters as plain text.
285
+ For example:
286
+
287
+ %title
288
+ = @title
289
+ \= @title
290
+
291
+ is compiled to:
292
+
293
+ <title>
294
+ MyPage
295
+ = @title
296
+ </title>
297
+
298
+ ## HTML Elements
299
+
300
+
301
+ ### Element Name: `%`
302
+
303
+ The percent character is placed at the beginning of a line.
304
+ It's followed immediately by the name of an element,
305
+ then optionally by modifiers (see below), a space,
306
+ and text to be rendered inside the element.
307
+ It creates an element in the form of `<element></element>`.
308
+ For example:
309
+
310
+ %one
311
+ %two
312
+ %three Hey there
313
+
314
+ is compiled to:
315
+
316
+ <one>
317
+ <two>
318
+ <three>Hey there</three>
319
+ </two>
320
+ </one>
321
+
322
+ Any string is a valid element name;
323
+ Haml will automatically generate opening and closing tags for any element.
324
+
325
+ ### Attributes: `{}` or `()` {#attributes}
326
+
327
+ Brackets represent a Ruby hash
328
+ that is used for specifying the attributes of an element.
329
+ It is literally evaluated as a Ruby hash,
330
+ so logic will work in it and local variables may be used.
331
+ Quote characters within the attribute
332
+ will be replaced by appropriate escape sequences.
333
+ The hash is placed after the tag is defined.
334
+ For example:
335
+
336
+ %html{:xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "en", :lang => "en"}
337
+
338
+ is compiled to:
339
+
340
+ <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'></html>
341
+
342
+ Attribute hashes can also be stretched out over multiple lines
343
+ to accommodate many attributes.
344
+ However, newlines may only be placed immediately after commas.
345
+ For example:
346
+
347
+ %script{:type => "text/javascript",
348
+ :src => "javascripts/script_#{2 + 7}"}
349
+
350
+ is compiled to:
351
+
352
+ <script src='javascripts/script_9' type='text/javascript'></script>
353
+
354
+ #### `:class` and `:id` Attributes
355
+ {#class-and-id-attributes}
356
+
357
+ The `:class` and `:id` attributes can also be specified as a Ruby array
358
+ whose elements will be joined together.
359
+ A `:class` array is joined with `" "`
360
+ and an `:id` array is joined with `"_"`.
361
+ For example:
362
+
363
+ %div{:id => [@item.type, @item.number], :class => [@item.type, @item.urgency]}
364
+
365
+ is equivalent to:
366
+
367
+ %div{:id => "#{@item.type}_#{@item.number}", :class => "#{@item.type} #{@item.urgency}"}
368
+
369
+ The array will first be flattened
370
+ and any elements that do not test as true will be removed.
371
+ The remaining elements will be converted to strings.
372
+ For example:
373
+
374
+ %div{:class => [@item.type, @item == @sortcol && [:sort, @sortdir]] } Contents
375
+
376
+ could render as any of:
377
+
378
+ <div class="numeric sort ascending">Contents</div>
379
+ <div class="numeric">Contents</div>
380
+ <div class="sort descending">Contents</div>
381
+ <div>Contents</div>
382
+
383
+ depending on whether `@item.type` is `"numeric"` or `nil`,
384
+ whether `@item == @sortcol`,
385
+ and whether `@sortdir` is `"ascending"` or `"descending"`.
386
+
387
+ If a single value is specified and it evaluates to false it is ignored;
388
+ otherwise it gets converted to a string.
389
+ For example:
390
+
391
+ .item{:class => @item.is_empty? && "empty"}
392
+
393
+ could render as either of:
394
+
395
+ class="item"
396
+ class="item empty"
397
+
398
+ #### HTML-style Attributes: `()`
399
+
400
+ Haml also supports a terser, less Ruby-specific attribute syntax
401
+ based on HTML's attributes.
402
+ These are used with parentheses instead of brackets, like so:
403
+
404
+ %html(xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en")
405
+
406
+ Ruby variables can be used by omitting the quotes.
407
+ Local variables or instance variables can be used.
408
+ For example:
409
+
410
+ %a(title=@title href=href) Stuff
411
+
412
+ This is the same as:
413
+
414
+ %a{:title => @title, :href => href} Stuff
415
+
416
+ Because there are no commas separating attributes, though,
417
+ more complicated expressions aren't allowed.
418
+ For those you'll have to use the `{}` syntax.
419
+ You can, however, use both syntaxes together:
420
+
421
+ %a(title=@title){:href => @link.href} Stuff
422
+
423
+ You can also use `#{}` interpolation to insert complicated expressions
424
+ in a HTML-style attribute:
425
+
426
+ %span(class="widget_#{@widget.number}")
427
+
428
+ HTML-style attributes can be stretched across multiple lines
429
+ just like hash-style attributes:
430
+
431
+ %script(type="text/javascript"
432
+ src="javascripts/script_#{2 + 7}")
433
+
434
+ #### Attribute Methods
435
+
436
+ A Ruby method call that returns a hash
437
+ can be substituted for the hash contents.
438
+ For example, {Haml::Helpers} defines the following method:
439
+
440
+ def html_attrs(lang = 'en-US')
441
+ {:xmlns => "http://www.w3.org/1999/xhtml", 'xml:lang' => lang, :lang => lang}
442
+ end
443
+
444
+ This can then be used in Haml, like so:
445
+
446
+ %html{html_attrs('fr-fr')}
447
+
448
+ This is compiled to:
449
+
450
+ <html lang='fr-fr' xml:lang='fr-fr' xmlns='http://www.w3.org/1999/xhtml'>
451
+ </html>
452
+
453
+ You can use as many such attribute methods as you want
454
+ by separating them with commas,
455
+ like a Ruby argument list.
456
+ All the hashes will me merged together, from left to right.
457
+ For example, if you defined
458
+
459
+ def hash1
460
+ {:bread => 'white', :filling => 'peanut butter and jelly'}
461
+ end
462
+
463
+ def hash2
464
+ {:bread => 'whole wheat'}
465
+ end
466
+
467
+ then
468
+
469
+ %sandwich{hash1, hash2, :delicious => true}/
470
+
471
+ would compile to:
472
+
473
+ <sandwich bread='whole wheat' delicious='true' filling='peanut butter and jelly' />
474
+
475
+ Note that the Haml attributes list has the same syntax as a Ruby method call.
476
+ This means that any attribute methods must come before the hash literal.
477
+
478
+ Attribute methods aren't supported for HTML-style attributes.
479
+
480
+ #### Boolean Attributes
481
+
482
+ Some attributes, such as "checked" for `input` tags or "selected" for `option` tags,
483
+ are "boolean" in the sense that their values don't matter -
484
+ it only matters whether or not they're present.
485
+ In HTML (but not XHTML), these attributes can be written as
486
+
487
+ <input selected>
488
+
489
+ To do this in Haml using hash-style attributes, just assign a Ruby
490
+ `true` value to the attribute:
491
+
492
+ %input{:selected => true}
493
+
494
+ In XHTML, the only valid value for these attributes is the name of the
495
+ attribute. Thus this will render in XHTML as
496
+
497
+ <input selected='selected'>
498
+
499
+ To set these attributes to false, simply assign them to a Ruby false value.
500
+ In both XHTML and HTML
501
+
502
+ %input{:selected => false}
503
+
504
+ will just render as
505
+
506
+ <input>
507
+
508
+ HTML-style boolean attributes can be written just like HTML:
509
+
510
+ %input(selected)
511
+
512
+ or using `true` and `false`:
513
+
514
+ %input(selected=true)
515
+
516
+ #### HTML5 Custom Data Attributes
517
+
518
+ HTML5 allows for adding [custom non-visible data attributes](http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#embedding-custom-non-visible-data)
519
+ to elements using attribute names beginning with `data-`.
520
+ Custom data attributes can be used in Haml by using the key `:data` with a Hash value
521
+ in an attribute hash.
522
+ Each of the key/value pairs in the Hash will be transformed into a custom data attribute.
523
+ For example:
524
+
525
+ %a{:href=>"/posts", :data => {:author_id => 123}} Posts By Author
526
+
527
+ will render as:
528
+
529
+ <a data-author-id='123' href='/posts'>Posts By Author</a>
530
+
531
+ Notice that the underscore in `author_id` was replaced by a hyphen. If you wish
532
+ to suppress this behavior, you can set Haml's [`:hyphenate_data_attrs`
533
+ option](#hyphenate_data_attrs-option) to `false`, and the output will be
534
+ rendered as:
535
+
536
+ <a data-author_id='123' href='/posts'>Posts By Author</a>
537
+
538
+ ### Class and ID: `.` and `#`
539
+
540
+ The period and pound sign are borrowed from CSS.
541
+ They are used as shortcuts to specify the `class`
542
+ and `id` attributes of an element, respectively.
543
+ Multiple class names can be specified in a similar way to CSS,
544
+ by chaining the class names together with periods.
545
+ They are placed immediately after the tag and before an attributes hash.
546
+ For example:
547
+
548
+ %div#things
549
+ %span#rice Chicken Fried
550
+ %p.beans{ :food => 'true' } The magical fruit
551
+ %h1.class.otherclass#id La La La
552
+
553
+ is compiled to:
554
+
555
+ <div id='things'>
556
+ <span id='rice'>Chicken Fried</span>
557
+ <p class='beans' food='true'>The magical fruit</p>
558
+ <h1 class='class otherclass' id='id'>La La La</h1>
559
+ </div>
560
+
561
+ And,
562
+
563
+ %div#content
564
+ %div.articles
565
+ %div.article.title Doogie Howser Comes Out
566
+ %div.article.date 2006-11-05
567
+ %div.article.entry
568
+ Neil Patrick Harris would like to dispel any rumors that he is straight
569
+
570
+ is compiled to:
571
+
572
+ <div id='content'>
573
+ <div class='articles'>
574
+ <div class='article title'>Doogie Howser Comes Out</div>
575
+ <div class='article date'>2006-11-05</div>
576
+ <div class='article entry'>
577
+ Neil Patrick Harris would like to dispel any rumors that he is straight
578
+ </div>
579
+ </div>
580
+ </div>
581
+
582
+ These shortcuts can be combined with long-hand attributes;
583
+ the two values will be merged together
584
+ as though they were all placed in an array
585
+ (see [the documentation on `:class` and `:id` attributes](#class-and-id-attributes)).
586
+ For example:
587
+
588
+ %div#Article.article.entry{:id => @article.number, :class => @article.visibility}
589
+
590
+ is equivalent to
591
+
592
+ %div{:id => ['Article', @article.number], :class => ['article', 'entry', @article.visibility]} Gabba Hey
593
+
594
+ and could compile to:
595
+
596
+ <div class="article entry visible" id="Article_27">Gabba Hey</div>
597
+
598
+ #### Implicit Div Elements
599
+
600
+ Because divs are used so often, they're the default elements.
601
+ If you only define a class and/or id using `.` or `#`,
602
+ a div is automatically used.
603
+ For example:
604
+
605
+ #collection
606
+ .item
607
+ .description What a cool item!
608
+
609
+ is the same as:
610
+
611
+ %div#collection
612
+ %div.item
613
+ %div.description What a cool item!
614
+
615
+ and is compiled to:
616
+
617
+ <div id='collection'>
618
+ <div class='item'>
619
+ <div class='description'>What a cool item!</div>
620
+ </div>
621
+ </div>
622
+
623
+ ### Self-Closing Tags: `/`
624
+
625
+ The forward slash character, when placed at the end of a tag definition,
626
+ causes the tag to be self-closed.
627
+ For example:
628
+
629
+ %br/
630
+ %meta{'http-equiv' => 'Content-Type', :content => 'text/html'}/
631
+
632
+ is compiled to:
633
+
634
+ <br />
635
+ <meta http-equiv='Content-Type' content='text/html' />
636
+
637
+ Some tags are automatically closed, as long as they have no content.
638
+ `meta`, `img`, `link`, `script`, `br`, and `hr` tags are closed by default.
639
+ This list can be customized by setting the [`:autoclose`](#autoclose-option) option.
640
+ For example:
641
+
642
+ %br
643
+ %meta{'http-equiv' => 'Content-Type', :content => 'text/html'}
644
+
645
+ is also compiled to:
646
+
647
+ <br />
648
+ <meta http-equiv='Content-Type' content='text/html' />
649
+
650
+ ### Whitespace Removal: `>` and `<`
651
+
652
+ `>` and `<` give you more control over the whitespace near a tag.
653
+ `>` will remove all whitespace surrounding a tag,
654
+ while `<` will remove all whitespace immediately within a tag.
655
+ You can think of them as alligators eating the whitespace:
656
+ `>` faces out of the tag and eats the whitespace on the outside,
657
+ and `<` faces into the tag and eats the whitespace on the inside.
658
+ They're placed at the end of a tag definition,
659
+ after class, id, and attribute declarations
660
+ but before `/` or `=`.
661
+ For example:
662
+
663
+ %blockquote<
664
+ %div
665
+ Foo!
666
+
667
+ is compiled to:
668
+
669
+ <blockquote><div>
670
+ Foo!
671
+ </div></blockquote>
672
+
673
+ And:
674
+
675
+ %img
676
+ %img>
677
+ %img
678
+
679
+ is compiled to:
680
+
681
+ <img /><img /><img />
682
+
683
+ And:
684
+
685
+ %p<= "Foo\nBar"
686
+
687
+ is compiled to:
688
+
689
+ <p>Foo
690
+ Bar</p>
691
+
692
+ And finally:
693
+
694
+ %img
695
+ %pre><
696
+ foo
697
+ bar
698
+ %img
699
+
700
+ is compiled to:
701
+
702
+ <img /><pre>foo
703
+ bar</pre><img />
704
+
705
+ ### Object Reference: `[]`
706
+
707
+ Square brackets follow a tag definition and contain a Ruby object
708
+ that is used to set the class and id of that tag.
709
+ The class is set to the object's class
710
+ (transformed to use underlines rather than camel case)
711
+ and the id is set to the object's class, followed by the value
712
+ of its `#to_key` or `#id` method (in that order).
713
+ This is most useful for elements that represent instances of Models.
714
+ Additionally, the second argument (if present) will be used as a prefix for
715
+ both the id and class attributes.
716
+ For example:
717
+
718
+ # file: app/controllers/users_controller.rb
719
+
720
+ def show
721
+ @user = CrazyUser.find(15)
722
+ end
723
+
724
+ -# file: app/views/users/show.haml
725
+
726
+ %div[@user, :greeting]
727
+ %bar[290]/
728
+ Hello!
729
+
730
+ is compiled to:
731
+
732
+ <div class='greeting_crazy_user' id='greeting_crazy_user_15'>
733
+ <bar class='fixnum' id='fixnum_581' />
734
+ Hello!
735
+ </div>
736
+
737
+ If you require that the class be something other than the underscored
738
+ object's class, you can implement the `haml_object_ref` method on the object.
739
+
740
+ # file: app/models/crazy_user.rb
741
+
742
+ class CrazyUser < ActiveRecord::Base
743
+ def haml_object_ref
744
+ "a_crazy_user"
745
+ end
746
+ end
747
+
748
+ -# file: app/views/users/show.haml
749
+
750
+ %div[@user]
751
+ Hello!
752
+
753
+ is compiled to:
754
+
755
+ <div class='a_crazy_user' id='a_crazy_user_15'>
756
+ Hello!
757
+ </div>
758
+
759
+
760
+ ## Doctype: `!!!`
761
+
762
+ When describing HTML documents with Haml,
763
+ you can have a document type or XML prolog generated automatically
764
+ by including the characters `!!!`.
765
+ For example:
766
+
767
+ !!! XML
768
+ !!!
769
+ %html
770
+ %head
771
+ %title Myspace
772
+ %body
773
+ %h1 I am the international space station
774
+ %p Sign my guestbook
775
+
776
+ is compiled to:
777
+
778
+ <?xml version='1.0' encoding='utf-8' ?>
779
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
780
+ <html>
781
+ <head>
782
+ <title>Myspace</title>
783
+ </head>
784
+ <body>
785
+ <h1>I am the international space station</h1>
786
+ <p>Sign my guestbook</p>
787
+ </body>
788
+ </html>
789
+
790
+ You can also specify the specific doctype after the `!!!`
791
+ When the [`:format`](#format-option) is set to `:xhtml` (the default except in Rails 3),
792
+ the following doctypes are supported:
793
+
794
+ `!!!`
795
+ : XHTML 1.0 Transitional<br/>
796
+ `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">`
797
+
798
+ `!!! Strict`
799
+ : XHTML 1.0 Strict<br/>
800
+ `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">`
801
+
802
+ `!!! Frameset`
803
+ : XHTML 1.0 Frameset<br/>
804
+ `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">`
805
+
806
+ `!!! 5`
807
+ : XHTML 5<br/>
808
+ `<!DOCTYPE html>`<br/>
809
+
810
+ `!!! 1.1`
811
+ : XHTML 1.1<br/>
812
+ `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">`
813
+
814
+ `!!! Basic`
815
+ : XHTML Basic 1.1<br/>
816
+ `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd"> `
817
+
818
+ `!!! Mobile`
819
+ : XHTML Mobile 1.2<br/>
820
+ `<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">`
821
+
822
+ `!!! RDFa`
823
+ : XHTML+RDFa 1.0<br/>
824
+ `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">`
825
+
826
+ When the [`:format`](#format-option) option is set to `:html4`,
827
+ the following doctypes are supported:
828
+
829
+ `!!!`
830
+ : HTML 4.01 Transitional<br/>
831
+ `<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">`
832
+
833
+ `!!! Strict`
834
+ : HTML 4.01 Strict<br/>
835
+ `<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">`
836
+
837
+ `!!! Frameset`
838
+ : HTML 4.01 Frameset<br/>
839
+ `<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">`
840
+
841
+ When the [`:format`](#format-option) option is set to `:html5`,
842
+ `!!!` is always `<!DOCTYPE html>`.
843
+
844
+ If you're not using the UTF-8 character set for your document,
845
+ you can specify which encoding should appear
846
+ in the XML prolog in a similar way.
847
+ For example:
848
+
849
+ !!! XML iso-8859-1
850
+
851
+ is compiled to:
852
+
853
+ <?xml version='1.0' encoding='iso-8859-1' ?>
854
+
855
+ If the mime_type of the template being rendered is `text/xml` then
856
+ a format of `:xhtml` will be used even if the global output format
857
+ is set to `:html4` or `:html5`.
858
+
859
+ ## Comments
860
+
861
+ Haml supports two sorts of comments:
862
+ those that show up in the HTML output
863
+ and those that don't.
864
+
865
+ ### HTML Comments: `/`
866
+
867
+ The forward slash character, when placed at the beginning of a line,
868
+ wraps all text after it in an HTML comment.
869
+ For example:
870
+
871
+ %peanutbutterjelly
872
+ / This is the peanutbutterjelly element
873
+ I like sandwiches!
874
+
875
+ is compiled to:
876
+
877
+ <peanutbutterjelly>
878
+ <!-- This is the peanutbutterjelly element -->
879
+ I like sandwiches!
880
+ </peanutbutterjelly>
881
+
882
+ The forward slash can also wrap indented sections of code. For example:
883
+
884
+ /
885
+ %p This doesn't render...
886
+ %div
887
+ %h1 Because it's commented out!
888
+
889
+ is compiled to:
890
+
891
+ <!--
892
+ <p>This doesn't render...</p>
893
+ <div>
894
+ <h1>Because it's commented out!</h1>
895
+ </div>
896
+ -->
897
+
898
+ #### Conditional Comments: `/[]`
899
+
900
+ You can also use [Internet Explorer conditional comments](http://www.quirksmode.org/css/condcom.html)
901
+ by enclosing the condition in square brackets after the `/`.
902
+ For example:
903
+
904
+ /[if IE]
905
+ %a{ :href => 'http://www.mozilla.com/en-US/firefox/' }
906
+ %h1 Get Firefox
907
+
908
+ is compiled to:
909
+
910
+ <!--[if IE]>
911
+ <a href='http://www.mozilla.com/en-US/firefox/'>
912
+ <h1>Get Firefox</h1>
913
+ </a>
914
+ <![endif]-->
915
+
916
+ ### Haml Comments: `-#`
917
+
918
+ The hyphen followed immediately by the pound sign
919
+ signifies a silent comment.
920
+ Any text following this isn't rendered in the resulting document
921
+ at all.
922
+
923
+ For example:
924
+
925
+ %p foo
926
+ -# This is a comment
927
+ %p bar
928
+
929
+ is compiled to:
930
+
931
+ <p>foo</p>
932
+ <p>bar</p>
933
+
934
+ You can also nest text beneath a silent comment.
935
+ None of this text will be rendered.
936
+ For example:
937
+
938
+ %p foo
939
+ -#
940
+ This won't be displayed
941
+ Nor will this
942
+ Nor will this.
943
+ %p bar
944
+
945
+ is compiled to:
946
+
947
+ <p>foo</p>
948
+ <p>bar</p>
949
+
950
+ ## Ruby Evaluation
951
+
952
+ ### Inserting Ruby: `=`
953
+
954
+ The equals character is followed by Ruby code.
955
+ This code is evaluated and the output is inserted into the document.
956
+ For example:
957
+
958
+ %p
959
+ = ['hi', 'there', 'reader!'].join " "
960
+ = "yo"
961
+
962
+ is compiled to:
963
+
964
+ <p>
965
+ hi there reader!
966
+ yo
967
+ </p>
968
+
969
+ If the [`:escape_html`](#escape_html-option) option is set, `=` will sanitize any
970
+ HTML-sensitive characters generated by the script. For example:
971
+
972
+ = '<script>alert("I\'m evil!");</script>'
973
+
974
+ would be compiled to
975
+
976
+ &lt;script&gt;alert(&quot;I'm evil!&quot;);&lt;/script&gt;
977
+
978
+ `=` can also be used at the end of a tag to insert Ruby code within that tag.
979
+ For example:
980
+
981
+ %p= "hello"
982
+
983
+ would be compiled to
984
+
985
+ <p>hello</p>
986
+
987
+ A line of Ruby code can be stretched over multiple lines
988
+ as long as each line but the last ends with a comma.
989
+ For example:
990
+
991
+ = link_to_remote "Add to cart",
992
+ :url => { :action => "add", :id => product.id },
993
+ :update => { :success => "cart", :failure => "error" }
994
+
995
+ Note that it's illegal to nest code within a tag that ends with `=`.
996
+
997
+ ### Running Ruby: `-`
998
+
999
+ The hyphen character is also followed by Ruby code.
1000
+ This code is evaluated but *not* inserted into the document.
1001
+
1002
+ **It is not recommended that you use this widely;
1003
+ almost all processing code and logic should be restricted
1004
+ to the Controller, the Helper, or partials.**
1005
+
1006
+ For example:
1007
+
1008
+ - foo = "hello"
1009
+ - foo << " there"
1010
+ - foo << " you!"
1011
+ %p= foo
1012
+
1013
+ is compiled to:
1014
+
1015
+ <p>
1016
+ hello there you!
1017
+ </p>
1018
+
1019
+ A line of Ruby code can be stretched over multiple lines
1020
+ as long as each line but the last ends with a comma.
1021
+ For example:
1022
+
1023
+ - links = {:home => "/",
1024
+ :docs => "/docs",
1025
+ :about => "/about"}
1026
+
1027
+ #### Ruby Blocks
1028
+
1029
+ Ruby blocks, like XHTML tags, don't need to be explicitly closed in Haml.
1030
+ Rather, they're automatically closed, based on indentation.
1031
+ A block begins whenever the indentation is increased
1032
+ after a Ruby evaluation command.
1033
+ It ends when the indentation decreases
1034
+ (as long as it's not an `else` clause or something similar).
1035
+ For example:
1036
+
1037
+ - (42...47).each do |i|
1038
+ %p= i
1039
+ %p See, I can count!
1040
+
1041
+ is compiled to:
1042
+
1043
+ <p>42</p>
1044
+ <p>43</p>
1045
+ <p>44</p>
1046
+ <p>45</p>
1047
+ <p>46</p>
1048
+ <p>See, I can count!</p>
1049
+
1050
+ Another example:
1051
+
1052
+ %p
1053
+ - case 2
1054
+ - when 1
1055
+ = "1!"
1056
+ - when 2
1057
+ = "2?"
1058
+ - when 3
1059
+ = "3."
1060
+
1061
+ is compiled to:
1062
+
1063
+ <p>
1064
+ 2?
1065
+ </p>
1066
+
1067
+ ### Whitespace Preservation: `~` {#tilde}
1068
+
1069
+ `~` works just like `=`, except that it runs {Haml::Helpers#find\_and\_preserve} on its input.
1070
+ For example,
1071
+
1072
+ ~ "Foo\n<pre>Bar\nBaz</pre>"
1073
+
1074
+ is the same as:
1075
+
1076
+ = find_and_preserve("Foo\n<pre>Bar\nBaz</pre>")
1077
+
1078
+ and is compiled to:
1079
+
1080
+ Foo
1081
+ <pre>Bar&#x000A;Baz</pre>
1082
+
1083
+ See also [Whitespace Preservation](#whitespace_preservation).
1084
+
1085
+ ### Ruby Interpolation: `#{}`
1086
+
1087
+ Ruby code can also be interpolated within plain text using `#{}`,
1088
+ similarly to Ruby string interpolation.
1089
+ For example,
1090
+
1091
+ %p This is #{h quality} cake!
1092
+
1093
+ is the same as
1094
+
1095
+ %p= "This is the #{h quality} cake!"
1096
+
1097
+ and might compile to
1098
+
1099
+ <p>This is scrumptious cake!</p>
1100
+
1101
+ Backslashes can be used to escape `#{}` strings,
1102
+ but they don't act as escapes anywhere else in the string.
1103
+ For example:
1104
+
1105
+ %p
1106
+ Look at \\#{h word} lack of backslash: \#{foo}
1107
+ And yon presence thereof: \{foo}
1108
+
1109
+ might compile to
1110
+
1111
+ <p>
1112
+ Look at \yon lack of backslash: #{foo}
1113
+ And yon presence thereof: \{foo}
1114
+ </p>
1115
+
1116
+ Interpolation can also be used within [filters](#filters).
1117
+ For example:
1118
+
1119
+ :javascript
1120
+ $(document).ready(function() {
1121
+ alert(#{@message.to_json});
1122
+ });
1123
+
1124
+ might compile to
1125
+
1126
+ <script type='text/javascript'>
1127
+ //<![CDATA[
1128
+ $(document).ready(function() {
1129
+ alert("Hi there!");
1130
+ });
1131
+ //]]>
1132
+ </script>
1133
+
1134
+ ### Escaping HTML: `&=` {#escaping_html}
1135
+
1136
+ An ampersand followed by one or two equals characters
1137
+ evaluates Ruby code just like the equals without the ampersand,
1138
+ but sanitizes any HTML-sensitive characters in the result of the code.
1139
+ For example:
1140
+
1141
+ &= "I like cheese & crackers"
1142
+
1143
+ compiles to
1144
+
1145
+ I like cheese &amp; crackers
1146
+
1147
+ If the [`:escape_html`](#escape_html-option) option is set,
1148
+ `&=` behaves identically to `=`.
1149
+
1150
+ `&` can also be used on its own so that `#{}` interpolation is escaped.
1151
+ For example,
1152
+
1153
+ & I like #{"cheese & crackers"}
1154
+
1155
+ compiles to
1156
+
1157
+ I like cheese &amp; crackers
1158
+
1159
+ ### Unescaping HTML: `!=` {#unescaping_html}
1160
+
1161
+ An exclamation mark followed by one or two equals characters
1162
+ evaluates Ruby code just like the equals would,
1163
+ but never sanitizes the HTML.
1164
+
1165
+ By default, the single equals doesn't sanitize HTML either.
1166
+ However, if the [`:escape_html`](#escape_html-option) option is set,
1167
+ `=` will sanitize the HTML, but `!=` still won't.
1168
+ For example, if `:escape_html` is set:
1169
+
1170
+ = "I feel <strong>!"
1171
+ != "I feel <strong>!"
1172
+
1173
+ compiles to
1174
+
1175
+ I feel &lt;strong&gt;!
1176
+ I feel <strong>!
1177
+
1178
+ `!` can also be used on its own so that `#{}` interpolation is unescaped.
1179
+ For example,
1180
+
1181
+ ! I feel #{"<strong>"}!
1182
+
1183
+ compiles to
1184
+
1185
+ I feel <strong>!
1186
+
1187
+ ## Filters {#filters}
1188
+
1189
+ The colon character designates a filter. This allows you to pass an indented
1190
+ block of text as input to another filtering program and add the result to the
1191
+ output of Haml. The syntax is simply a colon followed by the name of the filter.
1192
+ For example,
1193
+
1194
+ %p
1195
+ :markdown
1196
+ # Greetings
1197
+
1198
+ Hello, *World*
1199
+
1200
+ is compiled to
1201
+
1202
+ <p>
1203
+ <h1>Greetings</h1>
1204
+
1205
+ <p>Hello, <em>World</em></p>
1206
+ </p>
1207
+
1208
+ Filters can have Ruby code interpolated with `#{}`. For example,
1209
+
1210
+ - flavor = "raspberry"
1211
+ #content
1212
+ :textile
1213
+ I *really* prefer _#{flavor}_ jam.
1214
+
1215
+ is compiled to
1216
+
1217
+ <div id='content'>
1218
+ <p>I <strong>really</strong> prefer <em>raspberry</em> jam.</p>
1219
+ </div>
1220
+
1221
+ Currently, filters ignore the [`:escape_html`](#escape_html-option) option. This
1222
+ means that `#{}` interpolation within filters is never HTML-escaped.
1223
+
1224
+ The functionality of some filters such as Markdown can be provided by many
1225
+ different libraries. Usually you don't have to worry about this - you can just
1226
+ load the gem of your choice and Haml will automatically use it.
1227
+
1228
+ However in some cases you may want to make Haml explicitly use a specific gem
1229
+ to be used by a filter. In these cases you can do this via Tilt, the library
1230
+ Haml uses to implement many filters:
1231
+
1232
+ Tilt.prefer Tilt::RedCarpetTemplate
1233
+
1234
+ See the [Tilt documentation](https://github.com/rtomayko/tilt#fallback-mode) for
1235
+ more info.
1236
+
1237
+ Haml comes with the following filters defined:
1238
+
1239
+ {#cdata-filter}
1240
+ ### `:cdata`
1241
+ Surrounds the filtered text with CDATA tags.
1242
+
1243
+ {#coffee-filter}
1244
+ ### `:coffee`
1245
+ Compiles the filtered text to Javascript using Cofeescript. You can also
1246
+ reference this filter as `:coffeescript`. This filter is implemented using
1247
+ Tilt.
1248
+
1249
+ {#css-filter}
1250
+ ### `:css`
1251
+ Surrounds the filtered text with `<style>` and CDATA tags. Useful for including
1252
+ inline CSS.
1253
+
1254
+ {#erb-filter}
1255
+ ### `:erb`
1256
+ Parses the filtered text with ERb, like an RHTML template. Not available if the
1257
+ [`:suppress_eval`](#suppress_eval-option) option is set to true. Embedded Ruby
1258
+ code is evaluated in the same context as the Haml template. This filter is
1259
+ implemented using Tilt.
1260
+
1261
+ {#escaped-filter}
1262
+ ### `:escaped`
1263
+ Works the same as plain, but HTML-escapes the text
1264
+ before placing it in the document.
1265
+
1266
+ {#javascript-filter}
1267
+ ### `:javascript`
1268
+ Surrounds the filtered text with `<script>` and CDATA tags.
1269
+ Useful for including inline Javascript.
1270
+
1271
+ {#less-filter}
1272
+ ### `:less`
1273
+ Parses the filtered text with [Less](http://lesscss.org/) to produce CSS output.
1274
+ This filter is implemented using Tilt.
1275
+
1276
+
1277
+ {#markdown-filter}
1278
+ ### `:markdown`
1279
+ Parses the filtered text with
1280
+ [Markdown](http://daringfireball.net/projects/markdown). This filter is
1281
+ implemented using Tilt.
1282
+
1283
+ {#maruku-filter}
1284
+ ### `:maruku`
1285
+ Parses the filtered text with [Maruku](https://github.com/nex3/maruku), which
1286
+ has some non-standard extensions to Markdown.
1287
+
1288
+ As of Haml 3.2, this filter is defined in [Haml
1289
+ contrib](https://github.com/haml/haml-contrib) but is loaded automatically for
1290
+ historical reasons. In future versions of Haml it will likely not be loaded by
1291
+ default. This filter is implemented using Tilt.
1292
+
1293
+ {#plain-filter}
1294
+ ### `:plain`
1295
+ Does not parse the filtered text. This is useful for large blocks of text
1296
+ without HTML tags, when you don't want lines starting with `.` or `-` to be
1297
+ parsed.
1298
+
1299
+ {#preserve-filter}
1300
+ ### `:preserve`
1301
+ Inserts the filtered text into the template with whitespace preserved.
1302
+ `preserve`d blocks of text aren't indented, and newlines are replaced with the
1303
+ HTML escape code for newlines, to preserve nice-looking output. See also
1304
+ [Whitespace Preservation](#whitespace_preservation).
1305
+
1306
+ {#ruby-filter}
1307
+ ### `:ruby`
1308
+ Parses the filtered text with the normal Ruby interpreter. All output sent to
1309
+ `$stdout`, like with `puts`, is output into the Haml document. Not available if
1310
+ the [`:suppress_eval`](#suppress_eval-option) option is set to true. The Ruby
1311
+ code is evaluated in the same context as the Haml template.
1312
+
1313
+ {#sass-filter}
1314
+ ### `:sass`
1315
+ Parses the filtered text with [Sass](http://sass-lang.com/) to produce CSS
1316
+ output. This filter is implemented using Tilt.
1317
+
1318
+ {#scss-filter}
1319
+ ### `:scss`
1320
+ Parses the filtered text with Sass like the `:sass` filter, but uses the newer
1321
+ SCSS syntax to produce CSS output. This filter is implemented using Tilt.
1322
+
1323
+ {#textile-filter}
1324
+ ### `:textile`
1325
+ Parses the filtered text with [Textile](http://www.textism.com/tools/textile).
1326
+ Only works if [RedCloth](http://redcloth.org) is installed.
1327
+
1328
+ As of Haml 3.2, this filter is defined in [Haml
1329
+ contrib](https://github.com/haml/haml-contrib) but is loaded automatically for
1330
+ historical reasons. In future versions of Haml it will likely not be loaded by
1331
+ default. This filter is implemented using Tilt.
1332
+
1333
+ ### Custom Filters
1334
+
1335
+ You can also define your own filters. See {Haml::Filters} for details.
1336
+
1337
+ ## Multiline: `|` {#multiline}
1338
+
1339
+ The pipe character designates a multiline string.
1340
+ It's placed at the end of a line (after some whitespace)
1341
+ and means that all following lines that end with `|`
1342
+ will be evaluated as though they were on the same line.
1343
+ **Note that even the last line in the multiline block
1344
+ should end with `|`.**
1345
+ For example:
1346
+
1347
+ %whoo
1348
+ %hoo= h( |
1349
+ "I think this might get " + |
1350
+ "pretty long so I should " + |
1351
+ "probably make it " + |
1352
+ "multiline so it doesn't " + |
1353
+ "look awful.") |
1354
+ %p This is short.
1355
+
1356
+ is compiled to:
1357
+
1358
+ <whoo>
1359
+ <hoo>I think this might get pretty long so I should probably make it multiline so it doesn't look awful.</hoo>
1360
+ <p>This is short</p>
1361
+ </whoo>
1362
+
1363
+ Using multiline declarations in Haml is intentionally awkward.
1364
+ This is designed to discourage people from putting lots and lots of Ruby code
1365
+ in their Haml templates.
1366
+ If you find yourself using multiline declarations, stop and think:
1367
+ could I do this better with a helper?
1368
+
1369
+ Note that there are a few cases where it's useful to allow
1370
+ something to flow over onto multiple lines in a non-awkward manner.
1371
+ One of these is HTML attributes.
1372
+ Some elements just have lots of attributes,
1373
+ so you can wrap attributes without using `|` (see [Attributes](#attributes)).
1374
+
1375
+ In addition, sometimes you need to call Ruby methods or declare data structures
1376
+ that just need a lot of template information.
1377
+ So data structures and functions that require lots of arguments
1378
+ can be wrapped over multiple lines,
1379
+ as long as each line but the last ends in a comma
1380
+ (see [Inserting Ruby](#inserting_ruby_)).
1381
+
1382
+ ## Whitespace Preservation
1383
+
1384
+ Sometimes you don't want Haml to indent all your text.
1385
+ For example, tags like `pre` and `textarea` are whitespace-sensitive;
1386
+ indenting the text makes them render wrong.
1387
+
1388
+ Haml deals with this by "preserving" newlines before they're put into the document --
1389
+ converting them to the XHTML whitespace escape code, `&#x000A;`.
1390
+ Then Haml won't try to re-format the indentation.
1391
+
1392
+ Literal `textarea` and `pre` tags automatically preserve content given through `=`.
1393
+ Dynamically-generated `textarea`s and `pre`s can't be preserved automatically,
1394
+ and so should be passed through {Haml::Helpers#find\_and\_preserve} or the [`~` command](#tilde),
1395
+ which has the same effect.
1396
+
1397
+ Blocks of literal text can be preserved using the [`:preserve` filter](#preserve-filter).
1398
+
1399
+ ## Helpers
1400
+
1401
+ Haml offers a bunch of helpers that are useful for doing stuff like preserving
1402
+ whitespace, creating nicely indented output for user-defined helpers, and other
1403
+ useful things. The helpers are all documented in the {Haml::Helpers} and
1404
+ {Haml::Helpers::ActionViewExtensions} modules.