haml 6.0.0.beta.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/.github/FUNDING.yml +1 -0
  3. data/.github/workflows/test.yml +40 -0
  4. data/.gitignore +19 -0
  5. data/CHANGELOG.md +1515 -0
  6. data/FAQ.md +147 -0
  7. data/Gemfile +23 -0
  8. data/MIT-LICENSE +20 -0
  9. data/README.md +210 -0
  10. data/REFERENCE.md +1380 -0
  11. data/Rakefile +116 -0
  12. data/bin/bench +66 -0
  13. data/bin/console +11 -0
  14. data/bin/ruby +3 -0
  15. data/bin/setup +7 -0
  16. data/bin/stackprof +27 -0
  17. data/bin/test +24 -0
  18. data/exe/haml +6 -0
  19. data/ext/haml/extconf.rb +10 -0
  20. data/ext/haml/haml.c +537 -0
  21. data/ext/haml/hescape.c +108 -0
  22. data/ext/haml/hescape.h +20 -0
  23. data/haml.gemspec +47 -0
  24. data/lib/haml/ambles.rb +20 -0
  25. data/lib/haml/attribute_builder.rb +175 -0
  26. data/lib/haml/attribute_compiler.rb +128 -0
  27. data/lib/haml/attribute_parser.rb +110 -0
  28. data/lib/haml/cli.rb +154 -0
  29. data/lib/haml/compiler/children_compiler.rb +126 -0
  30. data/lib/haml/compiler/comment_compiler.rb +39 -0
  31. data/lib/haml/compiler/doctype_compiler.rb +46 -0
  32. data/lib/haml/compiler/script_compiler.rb +116 -0
  33. data/lib/haml/compiler/silent_script_compiler.rb +24 -0
  34. data/lib/haml/compiler/tag_compiler.rb +76 -0
  35. data/lib/haml/compiler.rb +97 -0
  36. data/lib/haml/dynamic_merger.rb +67 -0
  37. data/lib/haml/engine.rb +53 -0
  38. data/lib/haml/error.rb +16 -0
  39. data/lib/haml/escapable.rb +13 -0
  40. data/lib/haml/filters/base.rb +12 -0
  41. data/lib/haml/filters/cdata.rb +20 -0
  42. data/lib/haml/filters/coffee.rb +17 -0
  43. data/lib/haml/filters/css.rb +33 -0
  44. data/lib/haml/filters/erb.rb +10 -0
  45. data/lib/haml/filters/escaped.rb +22 -0
  46. data/lib/haml/filters/javascript.rb +33 -0
  47. data/lib/haml/filters/less.rb +20 -0
  48. data/lib/haml/filters/markdown.rb +11 -0
  49. data/lib/haml/filters/plain.rb +29 -0
  50. data/lib/haml/filters/preserve.rb +22 -0
  51. data/lib/haml/filters/ruby.rb +10 -0
  52. data/lib/haml/filters/sass.rb +15 -0
  53. data/lib/haml/filters/scss.rb +15 -0
  54. data/lib/haml/filters/text_base.rb +25 -0
  55. data/lib/haml/filters/tilt_base.rb +49 -0
  56. data/lib/haml/filters.rb +75 -0
  57. data/lib/haml/force_escapable.rb +29 -0
  58. data/lib/haml/haml_error.rb +66 -0
  59. data/lib/haml/helpers.rb +15 -0
  60. data/lib/haml/html.rb +22 -0
  61. data/lib/haml/identity.rb +13 -0
  62. data/lib/haml/object_ref.rb +30 -0
  63. data/lib/haml/parser.rb +986 -0
  64. data/lib/haml/rails_helpers.rb +51 -0
  65. data/lib/haml/rails_template.rb +55 -0
  66. data/lib/haml/railtie.rb +15 -0
  67. data/lib/haml/ruby_expression.rb +32 -0
  68. data/lib/haml/string_splitter.rb +20 -0
  69. data/lib/haml/template.rb +20 -0
  70. data/lib/haml/temple_line_counter.rb +31 -0
  71. data/lib/haml/util.rb +260 -0
  72. data/lib/haml/version.rb +4 -0
  73. data/lib/haml.rb +13 -0
  74. metadata +359 -0
data/CHANGELOG.md ADDED
@@ -0,0 +1,1515 @@
1
+ # Haml Changelog
2
+
3
+ ## 6.0.0
4
+
5
+ Not released yet
6
+ ([diff](https://github.com/haml/haml/compare/v5.2.2...main)).
7
+
8
+ * Replace the implementation with Hamlit
9
+ * Haml 6 is about 1.7x faster than Haml 5 in [this benchmark](benchmark/slim/run-benchmarks.rb).
10
+ * The parser is kept as is, but everything else is replaced.
11
+ * All Haml helpers except for `preserve` are removed.
12
+ * Some legacy Rails integration is removed.
13
+
14
+ ## 5.2.2
15
+
16
+ Released on July 27, 2021
17
+ ([diff](https://github.com/haml/haml/compare/v5.2.1...v5.2.2)).
18
+
19
+ * Support `config.action_view.annotate_rendered_view_with_filenames = true` of Rails 6.1
20
+
21
+ ## 5.2.1
22
+
23
+ Released on November 30, 2020
24
+ ([diff](https://github.com/haml/haml/compare/v5.2.0...v5.2.1)).
25
+
26
+ * Add in improved "multiline" support for attributes [#1043](https://github.com/haml/haml/issues/1043)
27
+
28
+ ## 5.2
29
+
30
+ Released on September 28, 2020
31
+ ([diff](https://github.com/haml/haml/compare/v5.1.2...v5.2.0)).
32
+
33
+ * Fix crash in the attribute optimizer when `#inspect` is overridden in TrueClass / FalseClass [#972](https://github.com/haml/haml/issues/972)
34
+ * Do not HTML-escape templates that are declared to be plaintext [#1014](https://github.com/haml/haml/issues/1014) (Thanks [@cesarizu](https://github.com/cesarizu))
35
+ * Class names are no longer ordered alphabetically, and now follow a new specification as laid out in REFERENCE [#306](https://github.com/haml/haml/issues/306)
36
+
37
+ ## 5.1.2
38
+
39
+ Released on August 6, 2019
40
+ ([diff](https://github.com/haml/haml/compare/v5.1.1...v5.1.2)).
41
+
42
+ * Fix crash in some environments such as New Relic by unfreezing string literals for ParseNode#inspect. [#1016](https://github.com/haml/haml/pull/1016) (thanks [Jalyna](https://github.com/jalyna))
43
+
44
+ ## 5.1.1
45
+
46
+ Released on May 25, 2019
47
+ ([diff](https://github.com/haml/haml/compare/v5.1.0...v5.1.1)).
48
+
49
+ * Fix NameError bug that happens on ruby 2.6.1-2.6.3 + haml 5.1.0 + rails < 5.1 + erubi. (Akira Matsuda)
50
+
51
+ ## 5.1.0
52
+
53
+ Released on May 16, 2019
54
+ ([diff](https://github.com/haml/haml/compare/v5.0.4...v5.1.0)).
55
+
56
+ * Rails 6 support [#1008](https://github.com/haml/haml/pull/1008) (thanks [Seb Jacobs](https://github.com/sebjacobs))
57
+ * Add `escape_filter_interpolations` option for backwards compatibility with haml 4 defaults [#984](https://github.com/haml/haml/pull/984) (thanks [Will Jordan](https://github.com/wjordan))
58
+ * Fix error on empty :javascript and :css filter blocks [#986](https://github.com/haml/haml/pull/986) (thanks [Will Jordan](https://github.com/wjordan))
59
+ * Respect changes in Haml::Options.defaults in `Haml::TempleEngine` options (Takashi Kokubun)
60
+ * Un-freeze TempleEngine precompiled string literals [#983](https://github.com/haml/haml/pull/983) (thanks [Will Jordan](https://github.com/wjordan))
61
+ * Various performance/memory improvements [#965](https://github.com/haml/haml/pull/965), [#966](https://github.com/haml/haml/pull/966), [#963](https://github.com/haml/haml/pull/963) (thanks [Dillon Welch](https://github.com/oniofchaos))
62
+ * Enable `frozen_string_literal` magic comment for all .rb files [#967](https://github.com/haml/haml/pull/967) (thanks [Dillon Welch](https://github.com/oniofchaos))
63
+
64
+ ## 5.0.4
65
+
66
+ Released on October 13, 2017
67
+ ([diff](https://github.com/haml/haml/compare/v5.0.3...v5.0.4)).
68
+
69
+ * Fix `haml -c --stdin` regression in 5.0.2. [#958](https://github.com/haml/haml/pull/958) (thanks [Timo Göllner](https://github.com/TeaMoe))
70
+ * Ruby 2.5 support (it wasn't working due to Ripper API change). (Akira Matsuda)
71
+
72
+ ## 5.0.3
73
+
74
+ Released on September 7, 2017
75
+ ([diff](https://github.com/haml/haml/compare/v5.0.2...v5.0.3)).
76
+
77
+ * Use `String#dump` instead of `String#inspect` to generate string literal. (Takashi Kokubun)
78
+ * Fix Erubi superclass mismatch error. [#952](https://github.com/haml/haml/pull/952) (thanks [Robin Daugherty](https://github.com/RobinDaugherty))
79
+
80
+ ## 5.0.2
81
+
82
+ Released on August 1, 2017
83
+ ([diff](https://github.com/haml/haml/compare/v5.0.1...v5.0.2)).
84
+
85
+ * Let `haml -c` fail if generated Ruby code is syntax error. [#880](https://github.com/haml/haml/issues/880) (Takashi Kokubun)
86
+ * Fix `NoMethodError` bug caused with Sprockets 3 and :sass filter. [#930](https://github.com/haml/haml/pull/930) (thanks [Gonzalez Maximiliano](https://github.com/emaxi))
87
+ * Fix `list_of` helper with multi-line content. [#933](https://github.com/haml/haml/pull/933) (thanks [Benoit Larroque](https://github.com/zetaben))
88
+ * Optimize rendering performance by changing timing to fix textareas. [#941](https://github.com/haml/haml/pull/941) (Takashi Kokubun)
89
+ * Fix `TypeError` with empty :ruby filter. [#942](https://github.com/haml/haml/pull/942) (Takashi Kokubun)
90
+ * Fix inconsistent attribute sort order. (Takashi Kokubun)
91
+
92
+ ## 5.0.1
93
+
94
+ Released on May 3, 2017
95
+ ([diff](https://github.com/haml/haml/compare/v5.0.0...v5.0.1)).
96
+
97
+ * Fix parsing attributes including string interpolation. [#917](https://github.com/haml/haml/pull/917) [#921](https://github.com/haml/haml/issues/921)
98
+ * Stop distributing test files in gem package and allow installing on Windows.
99
+ * Use ActionView's Erubi/Erubis handler for erb filter only on ActionView. [#914](https://github.com/haml/haml/pull/914)
100
+
101
+ ## 5.0.0
102
+
103
+ Released on April 26, 2017
104
+ ([diff](https://github.com/haml/haml/compare/4.0.7...v5.0.0)).
105
+
106
+ Breaking Changes
107
+
108
+ * Haml now requires Ruby 2.0.0 or above.
109
+ * Rails 3 is no longer supported, matching the official
110
+ [Maintenance Policy for Ruby on Rails](http://weblog.rubyonrails.org/2013/2/24/maintenance-policy-for-ruby-on-rails/).
111
+ Use Haml 4 if you want to use Rails 3.
112
+ (Tee Parham)
113
+ * Remove `:ugly` option ([#894](https://github.com/haml/haml/pull/894))
114
+ * The `haml` command's debug option (`-d`) no longer executes the Haml code, but
115
+ rather checks the generated Ruby syntax for errors.
116
+ * Drop parser/compiler accessor from `Haml::Engine`. Modify `Haml::Engine#initialize` options
117
+ or `Haml::Template.options` instead. (Takashi Kokubun)
118
+ * Drop dynamic quotes support and always escape `'` for `escape_html`/`escape_attrs` instead.
119
+ Also, escaped results are slightly changed and always unified to the same characters. (Takashi Kokubun)
120
+ * Don't preserve newlines in attributes. (Takashi Kokubun)
121
+ * HTML escape interpolated code in filters.
122
+ [#770](https://github.com/haml/haml/pull/770)
123
+ (Matt Wildig)
124
+
125
+ :javascript
126
+ #{JSON.generate(foo: "bar")}
127
+ Haml 4 output: {"foo":"bar"}
128
+ Haml 5 output: {&quot;foo&quot;:&quot;bar&quot;}
129
+
130
+ Added
131
+
132
+ * Add a tracing option. When enabled, Haml will output a data-trace attribute on each tag showing the path
133
+ to the source Haml file from which it was generated. Thanks [Alex Babkin](https://github.com/ababkin).
134
+ * Add `haml_tag_if` to render a block, conditionally wrapped in another element (Matt Wildig)
135
+ * Support Rails 5.1 Erubi template handler.
136
+ * Support Sprockets 3. Thanks [Sam Davies](https://github.com/samphilipd) and [Jeremy Venezia](https://github.com/jvenezia).
137
+ * General performance and memory usage improvements. (Akira Matsuda)
138
+ * Analyze attribute values by Ripper and render static attributes beforehand. (Takashi Kokubun)
139
+ * Optimize attribute rendering about 3x faster. (Takashi Kokubun)
140
+ * Add temple gem as dependency and create `Haml::TempleEngine` class.
141
+ Some methods in `Haml::Compiler` are migrated to `Haml::TempleEngine`. (Takashi Kokubun)
142
+
143
+ Fixed
144
+
145
+ * Fix for attribute merging. When an attribute method (or literal nested hash)
146
+ was used in an old style attribute hash and there is also a (non-static) new
147
+ style hash there is an error. The fix can result in different behavior in
148
+ some circumstances. See the [commit message](https://github.com/haml/haml/tree/e475b015d3171fb4c4f140db304f7970c787d6e3)
149
+ for detailed info. (Matt Wildig)
150
+ * Make escape_once respect hexadecimal references. (Matt Wildig)
151
+ * Don't treat the 'data' attribute specially when merging attribute hashes. (Matt Wildig and Norman Clarke)
152
+ * Fix #@foo and #$foo style interpolation that was not working in html_safe mode. (Akira Matsuda)
153
+ * Allow `@` as tag's class name. Thanks [Joe Bartlett](https://github.com/redoPop).
154
+ * Raise `Haml::InvalidAttributeNameError` when attribute name includes invalid characters. (Takashi Kokubun)
155
+ * Don't ignore unexpected exceptions on initializing `ActionView::OutputBuffer`. (Takashi Kokubun)
156
+
157
+ ## 4.0.7
158
+
159
+ Released on August 10, 2015
160
+ ([diff](https://github.com/haml/haml/compare/4.0.6...4.0.7)).
161
+
162
+ * Significantly improve performance of regexp used to fix whitespace handling in textareas (thanks [Stan Hu](https://github.com/stanhu)).
163
+
164
+ ## 4.0.6
165
+
166
+ Released on Dec 1, 2014 ([diff](https://github.com/haml/haml/compare/4.0.5...4.0.6)).
167
+
168
+ * Fix warning on Ruby 1.8.7 "regexp has invalid interval" (thanks [Elia Schito](https://github.com/elia)).
169
+
170
+ ## 4.0.5
171
+
172
+ Released on Jan 7, 2014 ([diff](https://github.com/haml/haml/compare/4.0.4...4.0.5)).
173
+
174
+ * Fix haml_concat appending unescaped HTML after a call to haml_tag.
175
+ * Fix for bug whereby when HAML :ugly option is "true",
176
+ ActionView::Helpers::CaptureHelper::capture returns the whole view buffer
177
+ when passed a block that returns nothing (thanks [Mircea
178
+ Moise](https://github.com/mmircea16)).
179
+
180
+ ## 4.0.4
181
+
182
+ Released on November 5, 2013 ([diff](https://github.com/haml/haml/compare/4.0.3...4.0.4)).
183
+
184
+ * Check for Rails::Railtie rather than Rails (thanks [Konstantin Shabanov](https://github.com/etehtsea)).
185
+ * Parser fix to allow literal '#' with suppress_eval (Matt Wildig).
186
+ * Helpers#escape_once works on frozen strings (as does
187
+ ERB::Util.html_escape_once for which it acts as a replacement in
188
+ Rails (thanks [Patrik Metzmacher](https://github.com/patrik)).
189
+ * Minor test fix (thanks [Mircea Moise](https://github.com/mmircea16)).
190
+
191
+ ## 4.0.3
192
+
193
+ Released May 21, 2013 ([diff](https://github.com/haml/haml/compare/4.0.2...4.0.3)).
194
+
195
+ * Compatibility with newer versions of Rails's Erubis handler.
196
+ * Fix Erubis handler for compatibility with Tilt 1.4.x, too.
197
+ * Small performance optimization for html_escape.
198
+ (thanks [Lachlan Sylvester](https://github.com/lsylvester))
199
+ * Documentation fixes.
200
+ * Documented some helper methods that were left out of the reference.
201
+ (thanks [Shane Riley](https://github.com/shaneriley))
202
+
203
+ ## 4.0.2
204
+
205
+ Released April 5, 2013 ([diff](https://github.com/haml/haml/compare/4.0.1...4.0.2)).
206
+
207
+ * Explicitly require Erubis to work around bug in older versions of Tilt.
208
+ * Fix :erb filter printing duplicate content in Rails views.
209
+ (thanks [Jori Hardman](https://github.com/jorihardman))
210
+ * Replace range with slice to reduce objects created by `capture_haml`.
211
+ (thanks [Tieg Zaharia](https://github.com/tiegz))
212
+ * Correct/improve some documentation.
213
+
214
+ ## 4.0.1
215
+
216
+ Released March 21, 2013 ([diff](https://github.com/haml/haml/compare/4.0.0...4.0.1)).
217
+
218
+ * Remove Rails 3.2.3+ textarea hack in favor of a more general solution.
219
+ * Fix some performance regressions.
220
+ * Fix support for Rails 4 `text_area` helper method.
221
+ * Fix data attribute flattening with singleton objects.
222
+ (thanks [Alisdair McDiarmid](https://github.com/alisdair))
223
+ * Fix support for sass-rails 4.0 beta.
224
+ (thanks [Ryunosuke SATO](https://github.com/tricknotes))
225
+ * Load "haml/template" in Railtie in order to prevent user options set in a
226
+ Rails initializer from being overwritten
227
+ * Don't depend on Rails in haml/template to allow using Haml with ActionView
228
+ but without Rails itself. (thanks [Hunter Haydel](https://github.com/wedgex))
229
+
230
+ ## 4.0.0
231
+
232
+ * The Haml executable now accepts an `--autoclose` option. You can now
233
+ specify a list of tags that should be autoclosed
234
+
235
+ * The `:ruby` filter no longer redirects $stdout to the Haml document, as this
236
+ is not thread safe. Instead it provides a `haml_io` local variable, which is
237
+ an IO object that writes to the document.
238
+
239
+ * HTML5 is now the default output format rather than XHTML. This was already
240
+ the default on Rails 3+, so many users will notice no difference.
241
+
242
+ * The :sass filter now wraps its output in a style tag, as do the new :less and
243
+ :scss filters. The :coffee filter wraps its output in a script tag.
244
+
245
+ * Haml now supports only Rails 3 and above, and Ruby 1.8.7 and above. If you
246
+ still need support for Rails 2 and Ruby 1.8.6, please use Haml 3.1.x which
247
+ will continue to be maintained for bug fixes.
248
+
249
+ * The :javascript and :css filters no longer add CDATA tags when the format is
250
+ html4 or html5. This can be overridden by setting the `cdata` option to
251
+ `true`. CDATA tags are always added when the format is xhtml.
252
+
253
+ * HTML2Haml has been extracted to a separate gem, creatively named "html2haml".
254
+
255
+ * The `:erb` filter now uses Rails's safe output buffer to provide XSS safety.
256
+
257
+ * Haml's internals have been refactored to move the parser, compiler and options
258
+ handling into independent classes, rather than including them all in the
259
+ Engine module. You can also specify your own custom Haml parser or compiler
260
+ class in Haml::Options in order to extend or modify Haml reasonably easily.
261
+
262
+ * Add an {file:REFERENCE.md#hyphenate_data_attrs-option `:hyphenate_data_attrs`
263
+ option} that converts underscores to hyphens in your HTML5 data keys. This is
264
+ a language change from 3.1 and is enabled by default.
265
+ (thanks to [Andrew Smith](https://github.com/fullsailor))
266
+
267
+ * All Hash attribute values are now treated as HTML5 data, regardless of key.
268
+ Previously only the "data" key was treated this way. Allowing arbitrary keys
269
+ means you can now easily use this feature for Aria attributes, among other
270
+ uses.
271
+ (thanks to [Elvin Efendi](https://github.com/ElvinEfendi))
272
+
273
+ * Added `remove_whitespace` option to always remove all whitespace around Haml
274
+ tags. (thanks to [Tim van der Horst](https://github.com/vdh))
275
+
276
+ * Haml now flattens deeply nested data attribute hashes. For example:
277
+
278
+ `.foo{:data => {:a => "b", :c => {:d => "e", :f => "g"}}}`
279
+
280
+ would render to:
281
+
282
+ `<div class='foo' data-a='b' data-c-d='e' data-c-f='g'></div>`
283
+
284
+ (thanks to [Péter Pál Koszta](https://github.com/koszta))
285
+
286
+ * Filters that rely on third-party template engines are now implemented using
287
+ [Tilt](http://github.com/rtomayko/tilt). Several new filters have been added, namely
288
+ SCSS (:scss), LessCSS, (:less), and Coffeescript (:coffee/:coffeescript).
289
+
290
+ Though the list of "official" filters is kept intentionally small, Haml comes
291
+ with a helper method that makes adding support for other Tilt-based template
292
+ engines trivial.
293
+
294
+ As of 4.0, Haml will also ship with a "haml-contrib" gem that includes useful
295
+ but less-frequently used filters and helpers. This includes several additional
296
+ filters such as Nokogiri, Yajl, Markaby, and others.
297
+
298
+ * Generate object references based on `#to_key` if it exists in preference to
299
+ `#id`.
300
+
301
+ * Performance improvements.
302
+ (thanks to [Chris Heald](https://github.com/cheald))
303
+
304
+ * Helper `list_of` takes an extra argument that is rendered into list item
305
+ attributes.
306
+ (thanks [Iain Barnett](http://iainbarnett.me.uk/))
307
+
308
+ * Fix parser to allow lines ending with `some_method?` to be a Ruby multinline.
309
+ (thanks to [Brad Ediger](https://github.com/bradediger))
310
+
311
+ * Always use :xhtml format when the mime_type of the rendered template is
312
+ 'text/xml'.
313
+ (thanks to [Stephen Bannasch](https://github.com/stepheneb))
314
+
315
+ * html2haml now includes an `--html-attributes` option.
316
+ (thanks [Stefan Natchev](https://github.com/snatchev))
317
+
318
+ * Fix for inner whitespace removal in loops.
319
+ (thanks [Richard Michael](https://github.com/richardkmichael))
320
+
321
+ * Use numeric character references rather than HTML entities when escaping
322
+ double quotes and apostrophes in attributes. This works around some bugs in
323
+ Internet Explorer earlier than version 9.
324
+ (thanks [Doug Mayer](https://github.com/doxavore))
325
+
326
+ * Fix multiline silent comments: Haml previously did not allow free indentation
327
+ inside multline silent comments.
328
+
329
+ * Fix ordering bug with partial layouts on Rails.
330
+ (thanks [Sam Pohlenz](https://github.com/spohlenz))
331
+
332
+ * Add command-line option to suppress script evaluation.
333
+
334
+ * It's now possible to use Rails's asset helpers inside the Sass and SCSS
335
+ filters. Note that to do so, you must make sure sass-rails is loaded in
336
+ production, usually by moving it out of the assets gem group.
337
+
338
+ * The Haml project now uses [semantic versioning](http://semver.org/).
339
+
340
+ ## 3.2.0
341
+
342
+ The Haml 3.2 series was released only as far as 3.2.0.rc.4, but then was
343
+ renamed to Haml 4.0 when the project adopted semantic versioning.
344
+
345
+ ## 3.1.8
346
+
347
+ * Fix for line numbers reported from exceptions in nested blocks
348
+ (thanks to Grant Hutchins & Sabrina Staedt).
349
+
350
+ ## 3.1.7
351
+
352
+ * Fix for compatibility with Sass 3.2.x.
353
+ (thanks [Michael Westbom](https://github.com/totallymike)).
354
+
355
+ ## 3.1.6
356
+
357
+ * In indented mode, don't reindent buffers that contain preserved tags, and
358
+ provide a better workaround for Rails 3.2.3's textarea helpers.
359
+
360
+ ## 3.1.5
361
+
362
+ * Respect Rails' `html_safe` flag when escaping attribute values
363
+ (thanks to [Gerad Suyderhoud](https://github.com/gerad)).
364
+
365
+ * Fix for Rails 3.2.3 textarea helpers
366
+ (thanks to [James Coleman](https://github.com/jcoleman) and others).
367
+
368
+ ## 3.1.4
369
+
370
+ * Fix the use of `FormBuilder#block` with a label in Haml.
371
+ * Fix indentation after a self-closing tag with dynamic attributes.
372
+
373
+ ## 3.1.3
374
+
375
+ * Stop partial layouts from being displayed twice.
376
+
377
+ ## 3.1.2
378
+
379
+ * If the ActionView `#capture` helper is used in a Haml template but without any Haml being run in the block,
380
+ return the value of the block rather than the captured buffer.
381
+
382
+ * Don't throw errors when text is nested within comments.
383
+
384
+ * Fix html2haml.
385
+
386
+ * Fix an issue where destructive modification was sometimes performed on Rails SafeBuffers.
387
+
388
+ * Use character code entities for attribute value replacements instead of named/keyword entities.
389
+
390
+ ## 3.1.1
391
+
392
+ * Update the vendored Sass to version 3.1.0.
393
+
394
+ ## 3.1.0
395
+
396
+ * Don't add a `type` attribute to `<script>` and `<style>` tags generated by filters
397
+ when `:format` is set to `:html5`.
398
+
399
+ * Add an {file:HAML_REFERENCE.md#escape_attrs-option `:escape_attrs` option}
400
+ that allows attributes to either remain unescaped
401
+ (for things like embedding PHP directives in Haml)
402
+ or to be always escaped rather than `#escape_once`d.
403
+ This can also be used from the command line via `--no-escape-attrs`.
404
+
405
+ * Allow custom filters to be loaded from the command line.
406
+
407
+ ### Backwards Incompatibilities -- Must Read!
408
+
409
+ * Get rid of the `--rails` flag for the `haml` executable.
410
+ This flag hasn't been necessary since Rails 2.0.
411
+ Existing Rails 2.0 installations will continue to work.
412
+
413
+ * Drop support for Hpricot 0.7. 0.8 has been out for nearly two years.
414
+
415
+ ## 3.0.25
416
+
417
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.25).
418
+
419
+ * HTML-to-Haml conversion now works within Ruby even if Hpricot is loaded before `haml/html`.
420
+
421
+ ## 3.0.24
422
+
423
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.24).
424
+
425
+ * `html2haml` now properly generates Haml for silent script expressions
426
+ nested within blocks.
427
+
428
+ * IronRuby compatibility. This is sort of a hack: IronRuby reports its version as 1.9,
429
+ but it doesn't support the encoding APIs, so we treat it as 1.8 instead.
430
+
431
+ ## 3.0.23
432
+
433
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.23).
434
+
435
+ * Fix the error message for unloadable modules when running the executables under Ruby 1.9.2.
436
+
437
+ * Fix an error when combining old-style and new-style attributes.
438
+
439
+ ## 3.0.22
440
+
441
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.22).
442
+
443
+ * Allow an empty line after `case` but before `when`.
444
+
445
+ * Remove `vendor/sass`, which snuck into the gem by mistake
446
+ and was causing trouble for Heroku users (thanks to [Jacques Crocker](http://railsjedi.com/)).
447
+
448
+ * Support the Rails 3.1 template handler API.
449
+
450
+ ## 3.0.21
451
+
452
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.21).
453
+
454
+ * Fix the permissions errors for good.
455
+
456
+ ## 3.0.20
457
+
458
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.20).
459
+
460
+ * Fix some permissions errors.
461
+
462
+ ## 3.0.19
463
+
464
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.19).
465
+
466
+ * Fix the `:encoding` option under Ruby 1.9.2.
467
+
468
+ * Fix interpolated if statement when HTML escaping is enabled.
469
+
470
+ * Allow the `--unix-newlines` flag to work on Unix, where it's a no-op.
471
+
472
+ ## 3.0.18
473
+
474
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.18).
475
+
476
+ * Don't require `rake` in the gemspec, for bundler compatibility under
477
+ JRuby. Thanks to [Gordon McCreight](http://www.gmccreight.com/blog).
478
+
479
+ * Get rid of the annoying RDoc errors on install.
480
+
481
+ * Disambiguate references to the `Rails` module when `haml-rails` is installed.
482
+
483
+ * Fix a bug in `haml_tag` that would allow duplicate attributes to be added
484
+ and make `data-` attributes not work.
485
+
486
+ * Compatibility with Rails 3 final.
487
+
488
+ ## 3.0.17
489
+
490
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.17).
491
+
492
+ * Understand that mingw counts as Windows.
493
+
494
+ ## 3.0.16
495
+
496
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.16).
497
+
498
+ * Fix an html2haml ERB-parsing bug where ERB blocks were occasionally
499
+ left without indentation in Haml.
500
+
501
+ * Fix parsing of `if` and `case` statements whose values were assigned to variables.
502
+ This is still bad style, though.
503
+
504
+ * Fix `form_for` and `form_tag` when they're passed a block that
505
+ returns a string in a helper.
506
+
507
+ ## 3.0.15
508
+
509
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.15).
510
+
511
+ There were no changes made to Haml between versions 3.0.14 and 3.0.15.
512
+
513
+ ## 3.0.14
514
+
515
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.14).
516
+
517
+ * Allow CSS-style classes and ids to contain colons.
518
+
519
+ * Fix an obscure bug with if statements.
520
+
521
+ ### Rails 3 Support
522
+
523
+ * Don't use the `#returning` method, which Rails 3 no longer provides.
524
+
525
+ ## 3.0.13
526
+
527
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.13).
528
+
529
+ ## Rails 3 Support
530
+
531
+ Support for Rails 3 versions prior to beta 4 has been removed.
532
+ Upgrade to Rails 3.0.0.beta4 if you haven't already.
533
+
534
+ ### Minor Improvements
535
+
536
+ * Properly process frozen strings with encoding declarations.
537
+
538
+ ## 3.0.12
539
+
540
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.12).
541
+
542
+ ## Rails 3 Support
543
+
544
+ Apparently the last version broke in new and exciting ways under Rails 3,
545
+ due to the inconsistent load order caused by certain combinations of gems.
546
+ 3.0.12 hacks around that inconsistency, and *should* be fully Rails 3-compatible.
547
+
548
+ ### Deprecated: Rails 3 Beta 3
549
+
550
+ Haml's support for Rails 3.0.0.beta.3 has been deprecated.
551
+ Haml 3.0.13 will only support 3.0.0.beta.4.
552
+
553
+ ## 3.0.11
554
+
555
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.11).
556
+
557
+ ## 3.0.10
558
+
559
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.10).
560
+
561
+ ### Appengine-JRuby Support
562
+
563
+ The way we determine the location of the Haml installation
564
+ no longer breaks the version of JRuby
565
+ used by [`appengine-jruby`](http://code.google.com/p/appengine-jruby/).
566
+
567
+ ### Bug Fixes
568
+
569
+ * Single-line comments are now handled properly by `html2haml`.
570
+
571
+ ## 3.0.9
572
+
573
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.9).
574
+
575
+ There were no changes made to Haml between versions 3.0.8 and 3.0.9.
576
+ A bug in Gemcutter caused the gem to be uploaded improperly.
577
+
578
+ ## 3.0.8
579
+
580
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.8).
581
+
582
+ * Fix a bug with Rails versions prior to Rails 3.
583
+
584
+ ## 3.0.7
585
+
586
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.7).
587
+
588
+ ### Encoding Support
589
+
590
+ Haml 3.0.7 adds support for Ruby-style `-# coding:` comments
591
+ for declaring the encoding of a template.
592
+ For details see {file:HAML_REFERENCE.md#encodings the reference}.
593
+
594
+ This also slightly changes the behavior of Haml when the
595
+ {file:HAML_REFERENCE.md#encoding-option `:encoding` option} is not set.
596
+ Rather than defaulting to `"utf-8"`,
597
+ it defaults to the encoding of the source document,
598
+ and only falls back to `"utf-8"` if this encoding is `"us-ascii"`.
599
+
600
+ The `haml` executable also now takes an `-E` option for specifying encoding,
601
+ which works the same way as Ruby's `-E` option.
602
+
603
+ ### Other Changes
604
+
605
+ * Default to the {file:HAML_REFERENCE.md#format-option `:html5` format}
606
+ when running under Rails 3,
607
+ since it defaults to HTML5 as well.
608
+
609
+ ### Bug Fixes
610
+
611
+ * When generating Haml for something like `<span>foo</span>,`,
612
+ use `= succeed` rather than `- succeed` (which doesn't work).
613
+
614
+ ## 3.0.6
615
+
616
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.6).
617
+
618
+ ### Rails 2.3.7 Support
619
+
620
+ This release fully supports Rails 2.3.7.
621
+
622
+ ### Rails 2.3.6 Support Removed
623
+
624
+ Rails 2.3.6 was released with various bugs related to XSS-protection
625
+ and interfacing with Haml.
626
+ Rails 2.3.7 was released shortly after with fixes for these bugs.
627
+ Thus, Haml no longer supports Rails 2.3.6,
628
+ and anyone using it should upgrade to 2.3.7.
629
+
630
+ Attempting to use Haml with Rails 2.3.6 will cause an error.
631
+
632
+ ## 3.0.5
633
+
634
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.5).
635
+
636
+ ### Rails 2.3.6 Support
637
+
638
+ This release hacks around various bugs in Rails 2.3.6,
639
+ bringing Haml up to full compatibility.
640
+
641
+ ### Rails 3 Support
642
+
643
+ Make sure the `#capture` helper in Rails 3
644
+ doesn't print its value directly to the template.
645
+
646
+ ## 3.0.4
647
+
648
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.4).
649
+
650
+ There were no changes made to Haml between versions 3.0.3 and 3.0.4.
651
+
652
+ ## 3.0.3
653
+
654
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.3).
655
+
656
+ ### Rails 3 Support
657
+
658
+ In order to make some Rails loading errors easier to debug,
659
+ Sass will now raise an error if `Rails.root` is `nil` when Sass is loading.
660
+ Previously, this would just cause the paths to be mis-set.
661
+
662
+ ## 3.0.2
663
+
664
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.2).
665
+
666
+ There were no changes made to Haml between versions 3.0.1 and 3.0.2.
667
+
668
+ ## 3.0.1
669
+
670
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.1).
671
+
672
+ ### Installation in Rails
673
+
674
+ `haml --rails` is no longer necessary for installing Haml in Rails.
675
+ Now all you need to do is add `gem "haml"` to the Gemfile for Rails 3,
676
+ or add `config.gem "haml"` to `config/environment.rb` for previous versions.
677
+
678
+ `haml --rails` will still work,
679
+ but it has been deprecated and will print an error message.
680
+ It will not work in the next version of Haml.
681
+
682
+ ### Rails Test Speed
683
+
684
+ The {file:HAML_REFERENCE.md#ugly-option `:ugly` option} is now on by default
685
+ in the testing environment in Rails to help tests run faster.
686
+
687
+ ## 3.0.0
688
+
689
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.0).
690
+
691
+ ### Backwards Incompatibilities: Must Read!
692
+
693
+ * The `puts` helper has been removed.
694
+ Use {Haml::Helpers#haml\_concat} instead.
695
+
696
+ ### More Useful Multiline
697
+
698
+ Ruby code can now be wrapped across multiple lines
699
+ as long as each line but the last ends in a comma.
700
+ For example:
701
+
702
+ = link_to_remote "Add to cart",
703
+ :url => { :action => "add", :id => product.id },
704
+ :update => { :success => "cart", :failure => "error" }
705
+
706
+ ### `haml_tag` and `haml_concat` Improvements
707
+
708
+ #### `haml_tag` with CSS Selectors
709
+
710
+ The {Haml::Helpers#haml_tag haml\_tag} helper can now take a string
711
+ using the same class/id shorthand as in standard Haml code.
712
+ Manually-specified class and id attributes are merged,
713
+ again as in standard Haml code.
714
+ For example:
715
+
716
+ haml_tag('#foo') #=> <div id='foo' />
717
+ haml_tag('.bar') #=> <div class='bar' />
718
+ haml_tag('span#foo.bar') #=> <span class='bar' id='foo' />
719
+ haml_tag('span#foo.bar', :class => 'abc') #=> <span class='abc bar' id='foo' />
720
+ haml_tag('span#foo.bar', :id => 'abc') #=> <span class='bar' id='abc_foo' />
721
+
722
+ Cheers, [S. Burkhard](http://github.com/hasclass/).
723
+
724
+ #### `haml_tag` with Multiple Lines of Content
725
+
726
+ The {Haml::Helpers#haml_tag haml\_tag} helper also does a better job
727
+ of formatting tags with multiple lines of content.
728
+ If a tag has multiple levels of content,
729
+ that content is indented beneath the tag.
730
+ For example:
731
+
732
+ haml_tag(:p, "foo\nbar") #=>
733
+ # <p>
734
+ # foo
735
+ # bar
736
+ # </p>
737
+
738
+ #### `haml_tag` with Multiple Lines of Content
739
+
740
+ Similarly, the {Haml::Helpers#haml_concat haml\_concat} helper
741
+ will properly indent multiple lines of content.
742
+ For example:
743
+
744
+ haml_tag(:p) {haml_concat "foo\nbar"} #=>
745
+ # <p>
746
+ # foo
747
+ # bar
748
+ # </p>
749
+
750
+ #### `haml_tag` and `haml_concat` with `:ugly`
751
+
752
+ When the {file:HAML_REFERENCE.md#ugly-option `:ugly` option} is enabled,
753
+ {Haml::Helpers#haml_tag haml\_tag} and {Haml::Helpers#haml_concat haml\_concat}
754
+ won't do any indentation of their arguments.
755
+
756
+ ### Basic Tag Improvements
757
+
758
+ * It's now possible to customize the name used for {file:HAML_REFERENCE.md#object_reference_ object reference}
759
+ for a given object by implementing the `haml_object_ref` method on that object.
760
+ This method should return a string that will be used in place of the class name of the object
761
+ in the generated class and id.
762
+ Thanks to [Tim Carey-Smith](http://twitter.com/halorgium).
763
+
764
+ * All attribute values may be non-String types.
765
+ Their `#to_s` method will be called to convert them to strings.
766
+ Previously, this only worked for attributes other than `class`.
767
+
768
+ ### `:class` and `:id` Attributes Accept Ruby Arrays
769
+
770
+ In an attribute hash, the `:class` attribute now accepts an Array
771
+ whose elements will be converted to strings and joined with <nobr>`" "`</nobr>.
772
+ Likewise, the `:id` attribute now accepts an Array
773
+ whose elements will be converted to strings and joined with `"_"`.
774
+ The array will first be flattened and any elements that do not test as true
775
+ will be stripped out. For example:
776
+
777
+ .column{:class => [@item.type, @item == @sortcol && [:sort, @sortdir]] }
778
+
779
+ could render as any of:
780
+
781
+ class="column numeric sort ascending"
782
+ class="column numeric"
783
+ class="column sort descending"
784
+ class="column"
785
+
786
+ depending on whether `@item.type` is `"numeric"` or `nil`,
787
+ whether `@item == @sortcol`,
788
+ and whether `@sortdir` is `"ascending"` or `"descending"`.
789
+
790
+ A single value can still be specified.
791
+ If that value evaluates to false it is ignored;
792
+ otherwise it gets converted to a string.
793
+ For example:
794
+
795
+ .item{:class => @item.is_empty? && "empty"}
796
+
797
+ could render as either of:
798
+
799
+ class="item"
800
+ class="item empty"
801
+
802
+ Thanks to [Ronen Barzel](http://www.ronenbarzel.org/).
803
+
804
+ ### HTML5 Custom Data Attributes
805
+
806
+ Creating an attribute named `:data` with a Hash value
807
+ will generate [HTML5 custom data attributes](http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#embedding-custom-non-visible-data).
808
+ For example:
809
+
810
+ %div{:data => {:author_id => 123, :post_id => 234}}
811
+
812
+ Will compile to:
813
+
814
+ <div data-author_id='123' data-post_id='234'></div>
815
+
816
+ Thanks to [John Reilly](http://twitter.com/johnreilly).
817
+
818
+ ### More Powerful `:autoclose` Option
819
+
820
+ The {file:HAML_REFERENCE.md#attributes_option `:attributes`} option
821
+ can now take regular expressions that specify which tags to make self-closing.
822
+
823
+ ### `--double-quote-attributes` Option
824
+
825
+ The Haml executable now has a `--double-quote-attributes` option (short form: `-q`)
826
+ that causes attributes to use a double-quote mark rather than single-quote.
827
+ Thanks to [Charles Roper](http://charlesroper.com/).
828
+
829
+ ### `:css` Filter
830
+
831
+ Haml now supports a {file:HAML_REFERENCE.md#css-filter `:css` filter}
832
+ that surrounds the filtered text with `<style>` and CDATA tags.
833
+
834
+ ### `haml-spec` Integration
835
+
836
+ We've added the cross-implementation tests from the [haml-spec](http://github.com/norman/haml-spec) project
837
+ to the standard Haml test suite, to be sure we remain compatible with the base functionality
838
+ of the many and varied [Haml implementations](http://en.wikipedia.org/wiki/Haml#Implementations).
839
+
840
+ ### Ruby 1.9 Support
841
+
842
+ * Haml and `html2haml` now produce more descriptive errors
843
+ when given a template with invalid byte sequences for that template's encoding,
844
+ including the line number and the offending character.
845
+
846
+ * Haml and `html2haml` now accept Unicode documents with a
847
+ [byte-order-mark](http://en.wikipedia.org/wiki/Byte_order_mark).
848
+
849
+ ### Rails Support
850
+
851
+ * When `form_for` is used with `=`, or `form_tag` is used with `=` and a block,
852
+ they will now raise errors explaining that they should be used with `-`.
853
+ This is similar to how {Haml::Helpers#haml\_concat} behaves,
854
+ and will hopefully clear up some difficult bugs for some users.
855
+
856
+ ### Rip Support
857
+
858
+ Haml is now compatible with the [Rip](http://hellorip.com/) package management system.
859
+ Thanks to [Josh Peek](http://joshpeek.com/).
860
+
861
+ ### `html2haml` Improvements
862
+
863
+ * Ruby blocks within ERB are now supported.
864
+ The Haml code is properly indented and the `end`s are removed.
865
+ This includes methods with blocks and all language constructs
866
+ such as `if`, `begin`, and `case`.
867
+ For example:
868
+
869
+ <% content_for :footer do %>
870
+ <p>Hi there!</p>
871
+ <% end %>
872
+
873
+ is now transformed into:
874
+
875
+ - content_for :footer do
876
+ %p Hi there!
877
+
878
+ Thanks to [Jack Chen](http://chendo.net) and [Dr. Nic Williams](http://drnicwilliams)
879
+ for inspiring this and creating the first draft of the code.
880
+
881
+ * Inline HTML text nodes are now transformed into inline Haml text.
882
+ For example, `<p>foo</p>` now becomes `%p foo`, whereas before it became:
883
+
884
+ %p
885
+ foo
886
+
887
+ The same is true for inline comments,
888
+ and inline ERB when running in ERB mode:
889
+ `<p><%= foo %></p>` will now become `%p= foo`.
890
+
891
+ * ERB included within text is now transformed into Ruby interpolation.
892
+ For example:
893
+
894
+ <p>
895
+ Foo <%= bar %> baz!
896
+ Flip <%= bang %>.
897
+ </p>
898
+
899
+ is now transformed into:
900
+
901
+ %p
902
+ Foo #{bar} baz!
903
+ Flip #{bang}.
904
+
905
+ * `<script>` tags are now transformed into `:javascript` filters,
906
+ and `<style>` tags into `:css` filters.
907
+ and indentation is preserved.
908
+ For example:
909
+
910
+ <script type="text/javascript">
911
+ function foo() {
912
+ return 12;
913
+ }
914
+ </script>
915
+
916
+ is now transformed into:
917
+
918
+ :javascript
919
+ function foo() {
920
+ return 12;
921
+ }
922
+
923
+ * `<pre>` and `<textarea>` tags are now transformed into the `:preserve` filter.
924
+ For example:
925
+
926
+ <pre>Foo
927
+ bar
928
+ baz</pre>
929
+
930
+ is now transformed into:
931
+
932
+ %pre
933
+ :preserve
934
+ Foo
935
+ bar
936
+ baz
937
+
938
+ * Self-closing tags (such as `<br />`) are now transformed into
939
+ self-closing Haml tags (like `%br/`).
940
+
941
+ * IE conditional comments are now properly parsed.
942
+
943
+ * Attributes are now output in a more-standard format,
944
+ without spaces within the curly braces
945
+ (e.g. `%p{:foo => "bar"}` as opposed to `%p{ :foo => "bar" }`).
946
+
947
+ * IDs and classes containing `#` and `.` are now output as string attributes
948
+ (e.g. `%p{:class => "foo.bar"}`).
949
+
950
+ * Attributes are now sorted, to maintain a deterministic order.
951
+
952
+ * `>` or {Haml::Helpers#succeed #succeed} are inserted where necessary
953
+ when inline formatting is used.
954
+
955
+ * Multi-line ERB statements are now properly indented,
956
+ and those without any content are removed.
957
+
958
+ ### Minor Improvements
959
+
960
+ * {Haml::Helpers#capture_haml capture\_haml} is now faster when using `:ugly`.
961
+ Thanks to [Alf Mikula](http://alfmikula.blogspot.com/).
962
+
963
+ * Add an `RDFa` doctype shortcut.
964
+
965
+ ## 2.2.24
966
+
967
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.24).
968
+
969
+ * Don't prevent ActiveModel form elements from having error formatting applied.
970
+
971
+ * Make sure `form_for` blocks are properly indented under Rails 3.0.0.beta.3.
972
+
973
+ * Don't activate a bug in the `dynamic_form` plugin under Rails 3.0.0.beta.3
974
+ that would cause its methods not to be loaded.
975
+
976
+ ## 2.2.23
977
+
978
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.23).
979
+
980
+ * Don't crash when `rake gems` is run in Rails with Haml installed.
981
+ Thanks to [Florian Frank](http://github.com/flori).
982
+
983
+ * Don't remove `\n` in filters with interpolation.
984
+
985
+ * Silence those annoying `"regexp match /.../n against to UTF-8 string"` warnings.
986
+
987
+ ## 2.2.22
988
+
989
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.22).
990
+
991
+ * Add a railtie so Haml and Sass will be automatically loaded in Rails 3.
992
+ Thanks to [Daniel Neighman](http://pancakestacks.wordpress.com/).
993
+
994
+ * Add a deprecation message for using `-` with methods like `form_for`
995
+ that return strings in Rails 3.
996
+ This is [the same deprecation that exists in Rails 3](http://github.com/rails/rails/commit/9de83050d3a4b260d4aeb5d09ec4eb64f913ba64).
997
+
998
+ * Make sure line numbers are reported correctly when filters are being used.
999
+
1000
+ * Make loading the gemspec not crash on read-only filesystems like Heroku's.
1001
+
1002
+ * Don't crash when methods like `form_for` return `nil` in, for example, Rails 3 beta.
1003
+
1004
+ * Compatibility with Rails 3 beta's RJS facilities.
1005
+
1006
+ ## 2.2.21
1007
+
1008
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.21).
1009
+
1010
+ * Fix a few bugs in the git-revision-reporting in Haml::Version.
1011
+ In particular, it will still work if `git gc` has been called recently,
1012
+ or if various files are missing.
1013
+
1014
+ * Always use `__FILE__` when reading files within the Haml repo in the `Rakefile`.
1015
+ According to [this bug report](http://github.com/carlhuda/bundler/issues/issue/44),
1016
+ this should make Haml work better with Bundler.
1017
+
1018
+ * Make the error message for `- end` a little more intuitive based on user feedback.
1019
+
1020
+ * Compatibility with methods like `form_for`
1021
+ that return strings rather than concatenate to the template in Rails 3.
1022
+
1023
+ * Add a {Haml::Helpers#with_tabs with_tabs} helper,
1024
+ which sets the indentation level for the duration of a block.
1025
+
1026
+ ## 2.2.20
1027
+
1028
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.20).
1029
+
1030
+ * The `form_tag` Rails helper is now properly marked as HTML-safe
1031
+ when using Rails' XSS protection with Rails 2.3.5.
1032
+
1033
+ * Calls to `defined?` shouldn't interfere with Rails' autoloading
1034
+ in very old versions (1.2.x).
1035
+
1036
+ * Fix a bug where calls to ActionView's `render` method
1037
+ with blocks and layouts wouldn't work under the Rails 3.0 beta.
1038
+
1039
+ * Fix a bug where the closing tags of nested calls to \{Haml::Helpers#haml\_concat}
1040
+ were improperly escaped under the Rails 3.0 beta.
1041
+
1042
+ ## 2.2.19
1043
+
1044
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.19).
1045
+
1046
+ * Fix a bug with the integration with Rails' XSS support.
1047
+ In particular, correctly override `safe_concat`.
1048
+
1049
+ ## 2.2.18
1050
+
1051
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.18).
1052
+
1053
+ * Support [the new XSS-protection API](http://yehudakatz.com/2010/02/01/safebuffers-and-rails-3-0/)
1054
+ used in Rails 3.
1055
+
1056
+ * Use `Rails.env` rather than `RAILS_ENV` when running under Rails 3.0.
1057
+ Thanks to [Duncan Grazier](http://duncangrazier.com/).
1058
+
1059
+ * Add a `--unix-newlines` flag to all executables
1060
+ for outputting Unix-style newlines on Windows.
1061
+
1062
+ * Fix a couple bugs with the `:erb` filter:
1063
+ make sure error reporting uses the correct line numbers,
1064
+ and allow multi-line expressions.
1065
+
1066
+ * Fix a parsing bug for HTML-style attributes including `#`.
1067
+
1068
+ ## 2.2.17
1069
+
1070
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.17).
1071
+
1072
+ * Fix compilation of HTML5 doctypes when using `html2haml`.
1073
+
1074
+ * `nil` values for Sass options are now ignored,
1075
+ rather than raising errors.
1076
+
1077
+ ## 2.2.16
1078
+
1079
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.16).
1080
+
1081
+ * Abstract out references to `ActionView::TemplateError`,
1082
+ `ActionView::TemplateHandler`, etc.
1083
+ These have all been renamed to `ActionView::Template::*`
1084
+ in Rails 3.0.
1085
+
1086
+ ## 2.2.15
1087
+
1088
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.15).
1089
+
1090
+ * Allow `if` statements with no content followed by `else` clauses.
1091
+ For example:
1092
+
1093
+ - if foo
1094
+ - else
1095
+ bar
1096
+
1097
+ ## 2.2.14
1098
+
1099
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.14).
1100
+
1101
+ * Don't print warnings when escaping attributes containing non-ASCII characters
1102
+ in Ruby 1.9.
1103
+
1104
+ * Don't crash when parsing an XHTML Strict doctype in `html2haml`.
1105
+
1106
+ * Support the HTML5 doctype in an XHTML document
1107
+ by using `!!! 5` as the doctype declaration.
1108
+
1109
+ ## 2.2.13
1110
+
1111
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.13).
1112
+
1113
+ * Allow users to specify {file:HAML_REFERENCE.md#encoding_option `:encoding => "ascii-8bit"`}
1114
+ even for templates that include non-ASCII byte sequences.
1115
+ This makes Haml templates not crash when given non-ASCII input
1116
+ that's marked as having an ASCII encoding.
1117
+
1118
+ * Fixed an incompatibility with Hpricot 0.8.2, which is used for `html2haml`.
1119
+
1120
+ ## 2.2.12
1121
+
1122
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.12).
1123
+
1124
+ There were no changes made to Haml between versions 2.2.11 and 2.2.12.
1125
+
1126
+ ## 2.2.11
1127
+
1128
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.11).
1129
+
1130
+ * Fixed a bug with XSS protection where HTML escaping would raise an error
1131
+ if passed a non-string value.
1132
+ Note that this doesn't affect any HTML escaping when XSS protection is disabled.
1133
+
1134
+ * Fixed a bug in outer-whitespace nuking where whitespace-only Ruby strings
1135
+ blocked whitespace nuking beyond them.
1136
+
1137
+ * Use `ensure` to protect the resetting of the Haml output buffer
1138
+ against exceptions that are raised within the compiled Haml code.
1139
+
1140
+ * Fix an error line-numbering bug that appeared if an error was thrown
1141
+ within loud script (`=`).
1142
+ This is not the best solution, as it disables a few optimizations,
1143
+ but it shouldn't have too much effect and the optimizations
1144
+ will hopefully be re-enabled in version 2.4.
1145
+
1146
+ * Don't crash if the plugin skeleton is installed and `rake gems:install` is run.
1147
+
1148
+ * Don't use `RAILS_ROOT` directly.
1149
+ This no longer exists in Rails 3.0.
1150
+ Instead abstract this out as `Haml::Util.rails_root`.
1151
+ This changes makes Haml fully compatible with edge Rails as of this writing.
1152
+
1153
+ ## 2.2.10
1154
+
1155
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.10).
1156
+
1157
+ * Fixed a bug where elements with dynamic attributes and no content
1158
+ would have too much whitespace between the opening and closing tag.
1159
+
1160
+ * Changed `rails/init.rb` away from loading `init.rb` and instead
1161
+ have it basically copy the content.
1162
+ This allows us to transfer the proper binding to `Haml.init_rails`.
1163
+
1164
+ * Make sure Haml only tries to enable XSS protection integration
1165
+ once all other plugins are loaded.
1166
+ This allows it to work properly when Haml is a gem
1167
+ and the `rails_xss` plugin is being used.
1168
+
1169
+ * Mark the return value of Haml templates as HTML safe.
1170
+ This makes Haml partials work with Rails' XSS protection.
1171
+
1172
+ ## 2.2.9
1173
+
1174
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.9).
1175
+
1176
+ * Fixed a bug where Haml's text was concatenated to the wrong buffer
1177
+ under certain circumstances.
1178
+ This was mostly an issue under Rails when using methods like `capture`.
1179
+
1180
+ * Fixed a bug where template text was escaped when there was interpolation in a line
1181
+ and the `:escape_html` option was enabled. For example:
1182
+
1183
+ Foo &lt; Bar #{"<"} Baz
1184
+
1185
+ with `:escape_html` used to render as
1186
+
1187
+ Foo &amp;lt; Bar &lt; Baz
1188
+
1189
+ but now renders as
1190
+
1191
+ Foo &lt; Bar &lt; Baz
1192
+
1193
+ ### Rails XSS Protection
1194
+
1195
+ Haml 2.2.9 supports the XSS protection in Rails versions 2.3.5+.
1196
+ There are several components to this:
1197
+
1198
+ * If XSS protection is enabled, Haml's {file:HAML_REFERENCE.md#escape_html-option `:escape_html`}
1199
+ option is set to `true` by default.
1200
+
1201
+ * Strings declared as HTML safe won't be escaped by Haml,
1202
+ including the {file:Haml/Helpers.html#html_escape-instance_method `#html_escape`} helper
1203
+ and `&=` if `:escape_html` has been disabled.
1204
+
1205
+ * Haml helpers that generate HTML are marked as HTML safe,
1206
+ and will escape their input if it's not HTML safe.
1207
+
1208
+ ## 2.2.8
1209
+
1210
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.8).
1211
+
1212
+ * Fixed a potential XSS issue with HTML escaping and wacky Unicode nonsense.
1213
+ This is the same as [the issue fixed in Rails](http://groups.google.com/group/rubyonrails-security/browse_thread/thread/48ab3f4a2c16190f) a bit ago.
1214
+
1215
+ ## 2.2.7
1216
+
1217
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.7).
1218
+
1219
+ * Fixed an `html2haml` issue where ERB attribute values
1220
+ weren't HTML-unescaped before being transformed into Haml.
1221
+
1222
+ * Fixed an `html2haml` issue where `#{}` wasn't escaped
1223
+ before being transformed into Haml.
1224
+
1225
+ * Add `<code>` to the list of tags that's
1226
+ {file:HAML_REFERENCE.md#preserve-option automatically whitespace-preserved}.
1227
+
1228
+ * Fixed a bug with `end` being followed by code in silent scripts -
1229
+ it no longer throws an error when it's nested beneath tags.
1230
+
1231
+ * Fixed a bug with inner whitespace-nuking and conditionals.
1232
+ The `else` et al. clauses of conditionals are now properly
1233
+ whitespace-nuked.
1234
+
1235
+ ## 2.2.6
1236
+
1237
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.6).
1238
+
1239
+ * Made the error message when unable to load a dependency for html2haml
1240
+ respect the `--trace` option.
1241
+
1242
+ * Don't crash when the `__FILE__` constant of a Ruby file is a relative path,
1243
+ as apparently happens sometimes in TextMate
1244
+ (thanks to [Karl Varga](http://github.com/kjvarga)).
1245
+
1246
+ * Add "Sass" to the `--version` string for the executables.
1247
+
1248
+ * Raise an exception when commas are omitted in static attributes
1249
+ (e.g. `%p{:foo => "bar" :baz => "bang"}`).
1250
+
1251
+ ## 2.2.5
1252
+
1253
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.5).
1254
+
1255
+ * Got rid of trailing whitespace produced when opening a conditional comment
1256
+ (thanks to [Norman Clarke](http://blog.njclarke.com/)).
1257
+
1258
+ * Fixed CSS id concatenation when a numeric id is given as an attribute.
1259
+ (thanks to [Norman Clarke](http://blog.njclarke.com/)).
1260
+
1261
+ * Fixed a couple bugs with using "-end" in strings.
1262
+
1263
+ ## 2.2.4
1264
+
1265
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.4).
1266
+
1267
+ * Allow `end` to be used for silent script when it's followed by code.
1268
+ For example:
1269
+
1270
+ - form_for do
1271
+ ...
1272
+ - end if @show_form
1273
+
1274
+ This isn't very good style, but we're supporting it for consistency's sake.
1275
+
1276
+ * Don't add `require 'rubygems'` to the top of init.rb when installed
1277
+ via `haml --rails`. This isn't necessary, and actually gets
1278
+ clobbered as soon as haml/template is loaded.
1279
+
1280
+ ## 2.2.3
1281
+
1282
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.3).
1283
+
1284
+ Haml 2.2.3 adds support for the JRuby bundling tools
1285
+ for Google AppEngine, thanks to [Jan Ulbrich](http://github.com/ulbrich).
1286
+
1287
+ ## 2.2.2
1288
+
1289
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.2).
1290
+
1291
+ Haml 2.2.2 is a minor bugfix release, with several notable changes.
1292
+ First, {file:Haml/Helpers.html#haml_concat-instance_method `haml_concat`}
1293
+ will now raise an error when used with `=`.
1294
+ This has always been incorrect behavior,
1295
+ and in fact has never actually worked.
1296
+ The only difference is that now it will fail loudly.
1297
+ Second, Ruby 1.9 is now more fully supported,
1298
+ especially with the {file:HAML_REFERENCE.md#htmlstyle_attributes_ new attribute syntax}.
1299
+ Third, filters are no longer escaped when the {file:HAML_REFERENCE.md#escape_html-option `:escape_html` option}
1300
+ is enabled and `#{}` interpolation is used.
1301
+
1302
+ ## 2.2.1
1303
+
1304
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.1).
1305
+
1306
+ Haml 2.2.1 is a minor bug-fix release.
1307
+
1308
+ ## 2.2.0
1309
+
1310
+ [Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.0).
1311
+
1312
+ Haml 2.2 adds several new features to the language,
1313
+ fixes several bugs, and dramatically improves performance
1314
+ (particularly when running with {file:HAML_REFERENCE.md#ugly-option `:ugly`} enabled).
1315
+
1316
+ ### Syntax Changes
1317
+
1318
+ #### HTML-Style Attribute Syntax
1319
+
1320
+ Haml 2.2 introduces a new syntax for attributes
1321
+ based on the HTML syntax.
1322
+ For example:
1323
+
1324
+ %a(href="http://haml.info" title="Haml's so cool!")
1325
+ %img(src="/images/haml.png" alt="Haml")
1326
+
1327
+ There are two main reasons for this.
1328
+ First, the hash-style syntax is very Ruby-specific.
1329
+ There are now [Haml implementations](http://en.wikipedia.org/wiki/Haml#Implementations)
1330
+ in many languages, each of which has its own syntax for hashes
1331
+ (or dicts or associative arrays or whatever they're called).
1332
+ The HTML syntax will be adopted by all of them,
1333
+ so you can feel comfortable using Haml in whichever language you need.
1334
+
1335
+ Second, the hash-style syntax is quite verbose.
1336
+ `%img{:src => "/images/haml.png", :alt => "Haml"}`
1337
+ is eight characters longer than `%img(src="/images/haml.png" alt="Haml")`.
1338
+ Haml's supposed to be about writing templates quickly and easily;
1339
+ HTML-style attributes should help out a lot with that.
1340
+
1341
+ Ruby variables can be used as attribute values by omitting quotes.
1342
+ Local variables or instance variables can be used.
1343
+ For example:
1344
+
1345
+ %a(title=@title href=href) Stuff
1346
+
1347
+ This is the same as:
1348
+
1349
+ %a{:title => @title, :href => href} Stuff
1350
+
1351
+ Because there are no commas separating attributes,
1352
+ more complicated expressions aren't allowed.
1353
+ You can use `#{}` interpolation to insert complicated expressions
1354
+ in a HTML-style attribute, though:
1355
+
1356
+ %span(class="widget_#{@widget.number}")
1357
+
1358
+ #### Multiline Attributes
1359
+
1360
+ In general, Haml tries to keep individual elements on a single line.
1361
+ There is a [multiline syntax](#multiline) for overflowing onto further lines,
1362
+ but it's intentionally awkward to use to encourage shorter lines.
1363
+
1364
+ However, there is one case where overflow is reasonable: attributes.
1365
+ Often a tag will simply have a lot of attributes, and in this case
1366
+ it makes sense to allow overflow.
1367
+ You can now stretch an attribute hash across multiple lines:
1368
+
1369
+ %script{:type => "text/javascript",
1370
+ :src => "javascripts/script_#{2 + 7}"}
1371
+
1372
+ This also works for HTML-style attributes:
1373
+
1374
+ %script(type="text/javascript"
1375
+ src="javascripts/script_#{2 + 7}")
1376
+
1377
+ Note that for hash-style attributes, the newlines must come after commas.
1378
+
1379
+ #### Universal interpolation
1380
+
1381
+ In Haml 2.0, you could use `==` to interpolate Ruby code
1382
+ within a line of text using `#{}`.
1383
+ In Haml 2.2, the `==` is unnecessary;
1384
+ `#{}` can be used in any text.
1385
+ For example:
1386
+
1387
+ %p This is a really cool #{h what_is_this}!
1388
+ But is it a #{h what_isnt_this}?
1389
+
1390
+ In addition, to {file:HAML_REFERENCE.md#escaping_html escape} or {file:HAML_REFERENCE.md#unescaping_html unescape}
1391
+ the interpolated code, you can just add `&` or `!`, respectively,
1392
+ to the beginning of the line:
1393
+
1394
+ %p& This is a really cool #{what_is_this}!
1395
+ & But is it a #{what_isnt_this}?
1396
+
1397
+ #### Flexible indentation
1398
+
1399
+ Haml has traditionally required its users to use two spaces of indentation.
1400
+ This is the universal Ruby style, and still highly recommended.
1401
+ However, Haml now allows any number of spaces or even tabs for indentation,
1402
+ provided:
1403
+
1404
+ * Tabs and spaces are not mixed
1405
+ * The indentation is consistent within a given document
1406
+
1407
+ ### New Options
1408
+
1409
+ #### `:ugly`
1410
+
1411
+ The `:ugly` option is not technically new;
1412
+ it was introduced in Haml 2.0 to make rendering deeply nested templates less painful.
1413
+ However, it's been greatly empowered in Haml 2.2.
1414
+ It now does all sorts of performance optimizations
1415
+ that couldn't be done before,
1416
+ and its use increases Haml's performance dramatically.
1417
+ It's enabled by default in production in Rails,
1418
+ and it's highly recommended for production environments
1419
+ in other frameworks.
1420
+
1421
+ #### `:encoding` {#encoding-option}
1422
+
1423
+ This option specifies the encoding of the Haml template
1424
+ when running under Ruby 1.9. It defaults to `Encoding.default_internal` or `"utf-8"`.
1425
+ This is useful for making sure that you don't get weird
1426
+ encoding errors when dealing with non-ASCII input data.
1427
+
1428
+ ### Deprecations
1429
+
1430
+ #### `Haml::Helpers#puts`
1431
+
1432
+ This helper is being deprecated for the obvious reason
1433
+ that it conflicts with the `Kernel#puts` method.
1434
+ I'm ashamed I ever chose this name.
1435
+ Use `haml_concat` instead and spare me the embarrassment.
1436
+
1437
+ #### `= haml_tag`
1438
+
1439
+ A lot of people accidentally use "`= haml_tag`".
1440
+ This has always been wrong; `haml_tag` outputs directly to the template,
1441
+ and so should be used as "`- haml_tag`".
1442
+ Now it raises an error when you use `=`.
1443
+
1444
+ ### Compatibility
1445
+
1446
+ #### Rails
1447
+
1448
+ Haml 2.2 is fully compatible with Rails,
1449
+ from 2.0.6 to the latest revision of edge, 783db25.
1450
+
1451
+ #### Ruby 1.9
1452
+
1453
+ Haml 2.2 is also fully compatible with Ruby 1.9.
1454
+ It supports Ruby 1.9-style attribute hashes,
1455
+ and handles encoding-related issues
1456
+ (see [the `:encoding` option](#encoding-option)).
1457
+
1458
+ ### Filters
1459
+
1460
+ #### `:markdown`
1461
+
1462
+ There are numerous improvements to the Markdown filter.
1463
+ No longer will Haml attempt to use RedCloth's inferior Markdown implementation.
1464
+ Instead, it will look for all major Markdown implementations:
1465
+ [RDiscount](https://github.com/rtomayko/rdiscount),
1466
+ [RPeg-Markdown](https://github.com/rtomayko/rpeg-markdown),
1467
+ [Maruku](http://maruku.rubyforge.org),
1468
+ and [BlueCloth](http://www.deveiate.org/projects/BlueCloth).
1469
+
1470
+ #### `:cdata`
1471
+
1472
+ There is now a `:cdata` filter for wrapping text in CDATA tags.
1473
+
1474
+ #### `:sass`
1475
+
1476
+ The `:sass` filter now uses options set in `Sass::Plugin`,
1477
+ if they're available.
1478
+
1479
+ ### Executables
1480
+
1481
+ #### `haml`
1482
+
1483
+ The `haml` executable now takes `-r` and `-I` flags
1484
+ that act just like the same flags for the `ruby` executable.
1485
+ This allows users to load helper files when using Haml
1486
+ from the command line.
1487
+
1488
+ It also takes a `--debug` flag that causes it to spit out
1489
+ the Ruby code that Haml generates from the template.
1490
+ This is more for my benefit than anything,
1491
+ but you may find it interesting.
1492
+
1493
+ #### `html2haml`
1494
+
1495
+ The `html2haml` executable has undergone significant improvements.
1496
+ Many of these are bugfixes, but there are also a few features.
1497
+ For one, it now understands CDATA tags and autodetects ERB files.
1498
+ In addition, a line containing just "`- end`" is now a Haml error;
1499
+ since it's not possible for `html2haml` to properly parse all Ruby blocks,
1500
+ this acts as a signal for the author that there are blocks
1501
+ to be dealt with.
1502
+
1503
+ ### Miscellaneous
1504
+
1505
+ #### XHTML Mobile DTD
1506
+
1507
+ Haml 2.2 supports a DTD for XHTML Mobile: `!!! Mobile`.
1508
+
1509
+ #### YARD
1510
+
1511
+ All the documentation for Haml 2.2, including this changelog,
1512
+ has been moved to [YARD](http://yard.soen.ca).
1513
+ YARD is an excellent documentation system,
1514
+ and allows us to write our documentation in [Maruku](http://maruku.rubyforge.org),
1515
+ which is also excellent.