haml 4.0.7 → 5.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/test.yml +36 -0
  3. data/.gitignore +19 -0
  4. data/.gitmodules +3 -0
  5. data/.yardopts +2 -3
  6. data/CHANGELOG.md +146 -4
  7. data/FAQ.md +4 -14
  8. data/Gemfile +16 -0
  9. data/MIT-LICENSE +2 -2
  10. data/README.md +90 -47
  11. data/REFERENCE.md +160 -74
  12. data/Rakefile +44 -63
  13. data/TODO +24 -0
  14. data/benchmark.rb +70 -0
  15. data/haml.gemspec +45 -0
  16. data/lib/haml/.gitattributes +1 -0
  17. data/lib/haml/attribute_builder.rb +219 -0
  18. data/lib/haml/attribute_compiler.rb +237 -0
  19. data/lib/haml/attribute_parser.rb +150 -0
  20. data/lib/haml/buffer.rb +12 -175
  21. data/lib/haml/compiler.rb +110 -320
  22. data/lib/haml/engine.rb +34 -41
  23. data/lib/haml/error.rb +28 -24
  24. data/lib/haml/escapable.rb +77 -0
  25. data/lib/haml/exec.rb +38 -20
  26. data/lib/haml/filters.rb +22 -27
  27. data/lib/haml/generator.rb +42 -0
  28. data/lib/haml/helpers/action_view_extensions.rb +4 -2
  29. data/lib/haml/helpers/action_view_mods.rb +45 -60
  30. data/lib/haml/helpers/action_view_xss_mods.rb +2 -0
  31. data/lib/haml/helpers/safe_erubi_template.rb +20 -0
  32. data/lib/haml/helpers/safe_erubis_template.rb +5 -1
  33. data/lib/haml/helpers/xss_mods.rb +23 -13
  34. data/lib/haml/helpers.rb +134 -89
  35. data/lib/haml/options.rb +63 -69
  36. data/lib/haml/parser.rb +319 -227
  37. data/lib/haml/plugin.rb +54 -0
  38. data/lib/haml/railtie.rb +43 -12
  39. data/lib/haml/sass_rails_filter.rb +18 -4
  40. data/lib/haml/template/options.rb +13 -2
  41. data/lib/haml/template.rb +13 -6
  42. data/lib/haml/temple_engine.rb +124 -0
  43. data/lib/haml/temple_line_counter.rb +30 -0
  44. data/lib/haml/util.rb +83 -202
  45. data/lib/haml/version.rb +3 -1
  46. data/lib/haml.rb +2 -0
  47. data/yard/default/.gitignore +1 -0
  48. data/yard/default/fulldoc/html/css/common.sass +15 -0
  49. data/yard/default/layout/html/footer.erb +12 -0
  50. metadata +73 -115
  51. data/lib/haml/template/plugin.rb +0 -41
  52. data/test/engine_test.rb +0 -2013
  53. data/test/erb/_av_partial_1.erb +0 -12
  54. data/test/erb/_av_partial_2.erb +0 -8
  55. data/test/erb/action_view.erb +0 -62
  56. data/test/erb/standard.erb +0 -55
  57. data/test/filters_test.rb +0 -254
  58. data/test/gemfiles/Gemfile.rails-3.0.x +0 -5
  59. data/test/gemfiles/Gemfile.rails-3.1.x +0 -6
  60. data/test/gemfiles/Gemfile.rails-3.2.x +0 -5
  61. data/test/gemfiles/Gemfile.rails-4.0.x +0 -5
  62. data/test/haml-spec/LICENSE +0 -14
  63. data/test/haml-spec/README.md +0 -106
  64. data/test/haml-spec/lua_haml_spec.lua +0 -38
  65. data/test/haml-spec/perl_haml_test.pl +0 -81
  66. data/test/haml-spec/ruby_haml_test.rb +0 -23
  67. data/test/haml-spec/tests.json +0 -660
  68. data/test/helper_test.rb +0 -583
  69. data/test/markaby/standard.mab +0 -52
  70. data/test/mocks/article.rb +0 -6
  71. data/test/parser_test.rb +0 -105
  72. data/test/results/content_for_layout.xhtml +0 -12
  73. data/test/results/eval_suppressed.xhtml +0 -9
  74. data/test/results/helpers.xhtml +0 -70
  75. data/test/results/helpful.xhtml +0 -10
  76. data/test/results/just_stuff.xhtml +0 -70
  77. data/test/results/list.xhtml +0 -12
  78. data/test/results/nuke_inner_whitespace.xhtml +0 -40
  79. data/test/results/nuke_outer_whitespace.xhtml +0 -148
  80. data/test/results/original_engine.xhtml +0 -20
  81. data/test/results/partial_layout.xhtml +0 -5
  82. data/test/results/partial_layout_erb.xhtml +0 -5
  83. data/test/results/partials.xhtml +0 -21
  84. data/test/results/render_layout.xhtml +0 -3
  85. data/test/results/silent_script.xhtml +0 -74
  86. data/test/results/standard.xhtml +0 -162
  87. data/test/results/tag_parsing.xhtml +0 -23
  88. data/test/results/very_basic.xhtml +0 -5
  89. data/test/results/whitespace_handling.xhtml +0 -90
  90. data/test/template_test.rb +0 -354
  91. data/test/templates/_av_partial_1.haml +0 -9
  92. data/test/templates/_av_partial_1_ugly.haml +0 -9
  93. data/test/templates/_av_partial_2.haml +0 -5
  94. data/test/templates/_av_partial_2_ugly.haml +0 -5
  95. data/test/templates/_layout.erb +0 -3
  96. data/test/templates/_layout_for_partial.haml +0 -3
  97. data/test/templates/_partial.haml +0 -8
  98. data/test/templates/_text_area.haml +0 -3
  99. data/test/templates/_text_area_helper.html.haml +0 -4
  100. data/test/templates/action_view.haml +0 -47
  101. data/test/templates/action_view_ugly.haml +0 -47
  102. data/test/templates/breakage.haml +0 -8
  103. data/test/templates/content_for_layout.haml +0 -8
  104. data/test/templates/eval_suppressed.haml +0 -11
  105. data/test/templates/helpers.haml +0 -55
  106. data/test/templates/helpful.haml +0 -11
  107. data/test/templates/just_stuff.haml +0 -85
  108. data/test/templates/list.haml +0 -12
  109. data/test/templates/nuke_inner_whitespace.haml +0 -32
  110. data/test/templates/nuke_outer_whitespace.haml +0 -144
  111. data/test/templates/original_engine.haml +0 -17
  112. data/test/templates/partial_layout.haml +0 -3
  113. data/test/templates/partial_layout_erb.erb +0 -4
  114. data/test/templates/partialize.haml +0 -1
  115. data/test/templates/partials.haml +0 -12
  116. data/test/templates/render_layout.haml +0 -2
  117. data/test/templates/silent_script.haml +0 -45
  118. data/test/templates/standard.haml +0 -43
  119. data/test/templates/standard_ugly.haml +0 -43
  120. data/test/templates/tag_parsing.haml +0 -21
  121. data/test/templates/very_basic.haml +0 -4
  122. data/test/templates/whitespace_handling.haml +0 -87
  123. data/test/test_helper.rb +0 -81
  124. data/test/util_test.rb +0 -63
@@ -1,23 +0,0 @@
1
- require "rubygems"
2
- require "minitest/autorun"
3
- require "json"
4
- require "haml"
5
-
6
- class HamlTest < MiniTest::Unit::TestCase
7
- contexts = JSON.parse(File.read(File.dirname(__FILE__) + "/tests.json"))
8
- contexts.each do |context|
9
- context[1].each do |name, test|
10
- define_method("test_spec: #{name} (#{context[0]})") do
11
- html = test["html"]
12
- haml = test["haml"]
13
- locals = Hash[(test["locals"] || {}).map {|x, y| [x.to_sym, y]}]
14
- options = Hash[(test["config"] || {}).map {|x, y| [x.to_sym, y]}]
15
- options[:format] = options[:format].to_sym if options.key?(:format)
16
- engine = Haml::Engine.new(haml, options)
17
- result = engine.render(Object.new, locals)
18
-
19
- assert_equal html, result.strip
20
- end
21
- end
22
- end
23
- end
@@ -1,660 +0,0 @@
1
- {
2
- "headers" : {
3
-
4
- "an XHTML XML prolog" : {
5
- "haml" : "!!! XML",
6
- "html" : "<?xml version='1.0' encoding='utf-8' ?>",
7
- "config" : {
8
- "format" : "xhtml"
9
- }
10
- },
11
-
12
- "an XHTML default (transitional) doctype" : {
13
- "haml" : "!!!",
14
- "html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">",
15
- "config" : {
16
- "format" : "xhtml"
17
- }
18
- },
19
-
20
- "an XHTML 1.1 doctype" : {
21
- "haml" : "!!! 1.1",
22
- "html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">",
23
- "config" : {
24
- "format" : "xhtml"
25
- }
26
- },
27
-
28
- "an XHTML 1.2 mobile doctype" : {
29
- "haml" : "!!! mobile",
30
- "html" : "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.2//EN\" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd\">",
31
- "config" : {
32
- "format" : "xhtml"
33
- }
34
- },
35
-
36
- "an XHTML 1.1 basic doctype" : {
37
- "haml" : "!!! basic",
38
- "html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML Basic 1.1//EN\" \"http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd\">",
39
- "config" : {
40
- "format" : "xhtml"
41
- }
42
- },
43
-
44
- "an XHTML 1.0 frameset doctype" : {
45
- "haml" : "!!! frameset",
46
- "html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">",
47
- "config" : {
48
- "format" : "xhtml"
49
- }
50
- },
51
-
52
- "an HTML 5 doctype with XHTML syntax" : {
53
- "haml" : "!!! 5",
54
- "html" : "<!DOCTYPE html>",
55
- "config" : {
56
- "format" : "xhtml"
57
- }
58
- },
59
-
60
- "an HTML 5 XML prolog (silent)" : {
61
- "haml" : "!!! XML",
62
- "html" : "",
63
- "config" : {
64
- "format" : "html5"
65
- }
66
- },
67
-
68
- "an HTML 5 doctype" : {
69
- "haml" : "!!!",
70
- "html" : "<!DOCTYPE html>",
71
- "config" : {
72
- "format" : "html5"
73
- }
74
- },
75
-
76
- "an HTML 4 XML prolog (silent)" : {
77
- "haml" : "!!! XML",
78
- "html" : "",
79
- "config" : {
80
- "format" : "html4"
81
- }
82
- },
83
-
84
- "an HTML 4 default (transitional) doctype" : {
85
- "haml" : "!!!",
86
- "html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
87
- "config" : {
88
- "format" : "html4"
89
- }
90
- },
91
-
92
- "an HTML 4 frameset doctype" : {
93
- "haml" : "!!! frameset",
94
- "html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\">",
95
- "config" : {
96
- "format" : "html4"
97
- }
98
- },
99
-
100
- "an HTML 4 strict doctype" : {
101
- "haml" : "!!! strict",
102
- "html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">",
103
- "config" : {
104
- "format" : "html4"
105
- }
106
- }
107
-
108
- },
109
-
110
- "basic Haml tags and CSS": {
111
-
112
- "a simple Haml tag" : {
113
- "haml" : "%p",
114
- "html" : "<p></p>"
115
- },
116
-
117
- "a self-closing tag (XHTML)" : {
118
- "haml" : "%meta",
119
- "html" : "<meta />",
120
- "config" : {
121
- "format" : "xhtml"
122
- }
123
- },
124
-
125
- "a self-closing tag (HTML4)" : {
126
- "haml" : "%meta",
127
- "html" : "<meta>",
128
- "config" : {
129
- "format" : "html4"
130
- }
131
- },
132
-
133
- "a self-closing tag (HTML5)" : {
134
- "haml" : "%meta",
135
- "html" : "<meta>",
136
- "config" : {
137
- "format" : "html5"
138
- }
139
- },
140
-
141
- "a self-closing tag ('/' modifier + XHTML)" : {
142
- "haml" : "%zzz/",
143
- "html" : "<zzz />",
144
- "config" : {
145
- "format" : "xhtml"
146
- }
147
- },
148
-
149
- "a self-closing tag ('/' modifier + HTML5)" : {
150
- "haml" : "%zzz/",
151
- "html" : "<zzz>",
152
- "config" : {
153
- "format" : "html5"
154
- }
155
- },
156
-
157
- "a tag with a CSS class" : {
158
- "haml" : "%p.class1",
159
- "html" : "<p class='class1'></p>"
160
- },
161
-
162
- "a tag with multiple CSS classes" : {
163
- "haml" : "%p.class1.class2",
164
- "html" : "<p class='class1 class2'></p>"
165
- },
166
-
167
- "a tag with a CSS id" : {
168
- "haml" : "%p#id1",
169
- "html" : "<p id='id1'></p>"
170
- },
171
-
172
- "a tag with multiple CSS id's" : {
173
- "haml" : "%p#id1#id2",
174
- "html" : "<p id='id2'></p>"
175
- },
176
-
177
- "a tag with a class followed by an id" : {
178
- "haml" : "%p.class1#id1",
179
- "html" : "<p class='class1' id='id1'></p>"
180
- },
181
-
182
- "a tag with an id followed by a class" : {
183
- "haml" : "%p#id1.class1",
184
- "html" : "<p class='class1' id='id1'></p>"
185
- },
186
-
187
- "an implicit div with a CSS id" : {
188
- "haml" : "#id1",
189
- "html" : "<div id='id1'></div>"
190
- },
191
-
192
- "an implicit div with a CSS class" : {
193
- "haml" : ".class1",
194
- "html" : "<div class='class1'></div>"
195
- },
196
-
197
- "multiple simple Haml tags" : {
198
- "haml" : "%div\n %div\n %p",
199
- "html" : "<div>\n <div>\n <p></p>\n </div>\n</div>"
200
- }
201
- },
202
-
203
- "tags with unusual HTML characters" : {
204
-
205
- "a tag with colons" : {
206
- "haml" : "%ns:tag",
207
- "html" : "<ns:tag></ns:tag>"
208
- },
209
-
210
- "a tag with underscores" : {
211
- "haml" : "%snake_case",
212
- "html" : "<snake_case></snake_case>"
213
- },
214
-
215
- "a tag with dashes" : {
216
- "haml" : "%dashed-tag",
217
- "html" : "<dashed-tag></dashed-tag>"
218
- },
219
-
220
- "a tag with camelCase" : {
221
- "haml" : "%camelCase",
222
- "html" : "<camelCase></camelCase>"
223
- },
224
-
225
- "a tag with PascalCase" : {
226
- "haml" : "%PascalCase",
227
- "html" : "<PascalCase></PascalCase>"
228
- }
229
- },
230
-
231
- "tags with unusual CSS identifiers" : {
232
-
233
- "an all-numeric class" : {
234
- "haml" : ".123",
235
- "html" : "<div class='123'></div>"
236
- },
237
-
238
- "a class with underscores" : {
239
- "haml" : ".__",
240
- "html" : "<div class='__'></div>"
241
- },
242
-
243
- "a class with dashes" : {
244
- "haml" : ".--",
245
- "html" : "<div class='--'></div>"
246
- }
247
- },
248
-
249
- "tags with inline content" : {
250
-
251
- "Inline content simple tag" : {
252
- "haml" : "%p hello",
253
- "html" : "<p>hello</p>"
254
- },
255
-
256
- "Inline content tag with CSS" : {
257
- "haml" : "%p.class1 hello",
258
- "html" : "<p class='class1'>hello</p>"
259
- },
260
-
261
- "Inline content multiple simple tags" : {
262
- "haml" : "%div\n %div\n %p text",
263
- "html" : "<div>\n <div>\n <p>text</p>\n </div>\n</div>"
264
- }
265
- },
266
-
267
- "tags with nested content" : {
268
-
269
- "Nested content simple tag" : {
270
- "haml" : "%p\n hello",
271
- "html" : "<p>\n hello\n</p>"
272
- },
273
-
274
- "Nested content tag with CSS" : {
275
- "haml" : "%p.class1\n hello",
276
- "html" : "<p class='class1'>\n hello\n</p>"
277
- },
278
-
279
- "Nested content multiple simple tags" : {
280
- "haml" : "%div\n %div\n %p\n text",
281
- "html" : "<div>\n <div>\n <p>\n text\n </p>\n </div>\n</div>"
282
- }
283
- },
284
-
285
- "tags with HTML-style attributes": {
286
-
287
- "HTML-style one attribute" : {
288
- "haml" : "%p(a='b')",
289
- "html" : "<p a='b'></p>"
290
- },
291
-
292
- "HTML-style multiple attributes" : {
293
- "haml" : "%p(a='b' c='d')",
294
- "html" : "<p a='b' c='d'></p>"
295
- },
296
-
297
- "HTML-style attributes separated with newlines" : {
298
- "haml" : "%p(a='b'\n c='d')",
299
- "html" : "<p a='b' c='d'></p>"
300
- },
301
-
302
- "HTML-style interpolated attribute" : {
303
- "haml" : "%p(a=\"#{var}\")",
304
- "html" : "<p a='value'></p>",
305
- "locals" : {
306
- "var" : "value"
307
- }
308
- },
309
-
310
- "HTML-style 'class' as an attribute" : {
311
- "haml" : "%p(class='class1')",
312
- "html" : "<p class='class1'></p>"
313
- },
314
-
315
- "HTML-style tag with a CSS class and 'class' as an attribute" : {
316
- "haml" : "%p.class2(class='class1')",
317
- "html" : "<p class='class1 class2'></p>"
318
- },
319
-
320
- "HTML-style tag with 'id' as an attribute" : {
321
- "haml" : "%p(id='1')",
322
- "html" : "<p id='1'></p>"
323
- },
324
-
325
- "HTML-style tag with a CSS id and 'id' as an attribute" : {
326
- "haml" : "%p#id(id='1')",
327
- "html" : "<p id='id_1'></p>"
328
- },
329
-
330
- "HTML-style tag with a variable attribute" : {
331
- "haml" : "%p(class=var)",
332
- "html" : "<p class='hello'></p>",
333
- "locals" : {
334
- "var" : "hello"
335
- }
336
- },
337
-
338
- "HTML-style tag with a CSS class and 'class' as a variable attribute" : {
339
- "haml" : ".hello(class=var)",
340
- "html" : "<div class='hello world'></div>",
341
- "locals" : {
342
- "var" : "world"
343
- }
344
- },
345
-
346
- "HTML-style tag multiple CSS classes (sorted correctly)" : {
347
- "haml" : ".z(class=var)",
348
- "html" : "<div class='a z'></div>",
349
- "locals" : {
350
- "var" : "a"
351
- }
352
- }
353
- },
354
-
355
- "tags with Ruby-style attributes": {
356
-
357
- "Ruby-style one attribute" : {
358
- "haml" : "%p{:a => 'b'}",
359
- "html" : "<p a='b'></p>",
360
- "optional" : true
361
- },
362
-
363
- "Ruby-style attributes hash with whitespace" : {
364
- "haml" : "%p{ :a => 'b' }",
365
- "html" : "<p a='b'></p>",
366
- "optional" : true
367
- },
368
-
369
- "Ruby-style interpolated attribute" : {
370
- "haml" : "%p{:a =>\"#{var}\"}",
371
- "html" : "<p a='value'></p>",
372
- "optional" : true,
373
- "locals" : {
374
- "var" : "value"
375
- }
376
- },
377
-
378
- "Ruby-style multiple attributes" : {
379
- "haml" : "%p{ :a => 'b', 'c' => 'd' }",
380
- "html" : "<p a='b' c='d'></p>",
381
- "optional" : true
382
- },
383
-
384
- "Ruby-style attributes separated with newlines" : {
385
- "haml" : "%p{ :a => 'b',\n 'c' => 'd' }",
386
- "html" : "<p a='b' c='d'></p>",
387
- "optional" : true
388
- },
389
-
390
- "Ruby-style 'class' as an attribute" : {
391
- "haml" : "%p{:class => 'class1'}",
392
- "html" : "<p class='class1'></p>",
393
- "optional" : true
394
- },
395
-
396
- "Ruby-style tag with a CSS class and 'class' as an attribute" : {
397
- "haml" : "%p.class2{:class => 'class1'}",
398
- "html" : "<p class='class1 class2'></p>",
399
- "optional" : true
400
- },
401
-
402
- "Ruby-style tag with 'id' as an attribute" : {
403
- "haml" : "%p{:id => '1'}",
404
- "html" : "<p id='1'></p>",
405
- "optional" : true
406
- },
407
-
408
- "Ruby-style tag with a CSS id and 'id' as an attribute" : {
409
- "haml" : "%p#id{:id => '1'}",
410
- "html" : "<p id='id_1'></p>",
411
- "optional" : true
412
- },
413
-
414
- "Ruby-style tag with a CSS id and a numeric 'id' as an attribute" : {
415
- "haml" : "%p#id{:id => 1}",
416
- "html" : "<p id='id_1'></p>",
417
- "optional" : true
418
- },
419
-
420
- "Ruby-style tag with a variable attribute" : {
421
- "haml" : "%p{:class => var}",
422
- "html" : "<p class='hello'></p>",
423
- "optional" : true,
424
- "locals" : {
425
- "var" : "hello"
426
- }
427
- },
428
-
429
- "Ruby-style tag with a CSS class and 'class' as a variable attribute" : {
430
- "haml" : ".hello{:class => var}",
431
- "html" : "<div class='hello world'></div>",
432
- "optional" : true,
433
- "locals" : {
434
- "var" : "world"
435
- }
436
- },
437
-
438
- "Ruby-style tag multiple CSS classes (sorted correctly)" : {
439
- "haml" : ".z{:class => var}",
440
- "html" : "<div class='a z'></div>",
441
- "optional" : true,
442
- "locals" : {
443
- "var" : "a"
444
- }
445
- }
446
- },
447
-
448
- "silent comments" : {
449
-
450
- "an inline silent comment" : {
451
- "haml" : "-# hello",
452
- "html" : ""
453
- },
454
-
455
- "a nested silent comment" : {
456
- "haml" : "-#\n hello",
457
- "html" : ""
458
- },
459
-
460
- "a multiply nested silent comment" : {
461
- "haml" : "-#\n %div\n foo",
462
- "html" : ""
463
- },
464
-
465
- "a multiply nested silent comment with inconsistent indents" : {
466
- "haml" : "-#\n %div\n foo",
467
- "html" : ""
468
- }
469
- },
470
-
471
- "markup comments" : {
472
-
473
- "an inline markup comment" : {
474
- "haml" : "/ comment",
475
- "html" : "<!-- comment -->"
476
- },
477
-
478
- "a nested markup comment" : {
479
- "haml" : "/\n comment\n comment2",
480
- "html" : "<!--\n comment\n comment2\n-->"
481
- }
482
- },
483
-
484
- "conditional comments": {
485
- "a conditional comment" : {
486
- "haml" : "/[if IE]\n %p a",
487
- "html" : "<!--[if IE]>\n <p>a</p>\n<![endif]-->"
488
- }
489
- },
490
-
491
- "internal filters": {
492
-
493
- "content in an 'escaped' filter" : {
494
- "haml" : ":escaped\n <&\">",
495
- "html" : "&lt;&amp;&quot;&gt;"
496
- },
497
-
498
- "content in a 'preserve' filter" : {
499
- "haml" : ":preserve\n hello\n\n%p",
500
- "html" : "hello&#x000A;\n<p></p>"
501
- },
502
-
503
- "content in a 'plain' filter" : {
504
- "haml" : ":plain\n hello\n\n%p",
505
- "html" : "hello\n<p></p>"
506
- },
507
-
508
- "content in a 'css' filter (XHTML)" : {
509
- "haml" : ":css\n hello\n\n%p",
510
- "html" : "<style type='text/css'>\n /*<![CDATA[*/\n hello\n /*]]>*/\n</style>\n<p></p>",
511
- "config" : {
512
- "format" : "xhtml"
513
- }
514
- },
515
-
516
- "content in a 'javascript' filter (XHTML)" : {
517
- "haml" : ":javascript\n a();\n%p",
518
- "html" : "<script type='text/javascript'>\n //<![CDATA[\n a();\n //]]>\n</script>\n<p></p>",
519
- "config" : {
520
- "format" : "xhtml"
521
- }
522
- },
523
-
524
- "content in a 'css' filter (HTML)" : {
525
- "haml" : ":css\n hello\n\n%p",
526
- "html" : "<style>\n hello\n</style>\n<p></p>",
527
- "config" : {
528
- "format" : "html5"
529
- }
530
- },
531
-
532
- "content in a 'javascript' filter (HTML)" : {
533
- "haml" : ":javascript\n a();\n%p",
534
- "html" : "<script>\n a();\n</script>\n<p></p>",
535
- "config" : {
536
- "format" : "html5"
537
- }
538
- }
539
- },
540
-
541
- "Ruby-style interpolation": {
542
-
543
- "interpolation inside inline content" : {
544
- "haml" : "%p #{var}",
545
- "html" : "<p>value</p>",
546
- "optional" : true,
547
- "locals" : {
548
- "var" : "value"
549
- }
550
- },
551
-
552
- "no interpolation when escaped" : {
553
- "haml" : "%p \\#{var}",
554
- "html" : "<p>#{var}</p>",
555
- "optional" : true,
556
- "locals" : {
557
- "var" : "value"
558
- }
559
- },
560
-
561
- "interpolation when the escape character is escaped" : {
562
- "haml" : "%p \\\\#{var}",
563
- "html" : "<p>\\value</p>",
564
- "optional" : true,
565
- "locals" : {
566
- "var" : "value"
567
- }
568
- },
569
-
570
- "interpolation inside filtered content" : {
571
- "haml" : ":plain\n #{var} interpolated: #{var}",
572
- "html" : "value interpolated: value",
573
- "optional" : true,
574
- "locals" : {
575
- "var" : "value"
576
- }
577
- }
578
- },
579
-
580
- "HTML escaping" : {
581
-
582
- "code following '&='" : {
583
- "haml" : "&= '<\"&>'",
584
- "html" : "&lt;&quot;&amp;&gt;"
585
- },
586
-
587
- "code following '=' when escape_haml is set to true" : {
588
- "haml" : "= '<\"&>'",
589
- "html" : "&lt;&quot;&amp;&gt;",
590
- "config" : {
591
- "escape_html" : "true"
592
- }
593
- },
594
-
595
- "code following '!=' when escape_haml is set to true" : {
596
- "haml" : "!= '<\"&>'",
597
- "html" : "<\"&>",
598
- "config" : {
599
- "escape_html" : "true"
600
- }
601
- }
602
-
603
- },
604
-
605
- "boolean attributes" : {
606
-
607
- "boolean attribute with XHTML" : {
608
- "haml" : "%input(checked=true)",
609
- "html" : "<input checked='checked' />",
610
- "config" : {
611
- "format" : "xhtml"
612
- }
613
- },
614
-
615
- "boolean attribute with HTML" : {
616
- "haml" : "%input(checked=true)",
617
- "html" : "<input checked>",
618
- "config" : {
619
- "format" : "html5"
620
- }
621
- }
622
- },
623
-
624
- "whitespace preservation" : {
625
-
626
- "following the '~' operator" : {
627
- "haml" : "~ \"Foo\\n<pre>Bar\\nBaz</pre>\"",
628
- "html" : "Foo\n<pre>Bar&#x000A;Baz</pre>",
629
- "optional" : true
630
- },
631
-
632
- "inside a textarea tag" : {
633
- "haml" : "%textarea\n hello\n hello",
634
- "html" : "<textarea>hello\nhello</textarea>"
635
- },
636
-
637
- "inside a pre tag" : {
638
- "haml" : "%pre\n hello\n hello",
639
- "html" : "<pre>hello\nhello</pre>"
640
- }
641
- },
642
-
643
- "whitespace removal" : {
644
-
645
- "a tag with '>' appended and inline content" : {
646
- "haml" : "%li hello\n%li> world\n%li again",
647
- "html" : "<li>hello</li><li>world</li><li>again</li>"
648
- },
649
-
650
- "a tag with '>' appended and nested content" : {
651
- "haml" : "%li hello\n%li>\n world\n%li again",
652
- "html" : "<li>hello</li><li>\n world\n</li><li>again</li>"
653
- },
654
-
655
- "a tag with '<' appended" : {
656
- "haml" : "%p<\n hello\n world",
657
- "html" : "<p>hello\nworld</p>"
658
- }
659
- }
660
- }