haml 4.0.7 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -1
  3. data/CHANGELOG.md +42 -4
  4. data/FAQ.md +4 -14
  5. data/MIT-LICENSE +1 -1
  6. data/README.md +85 -42
  7. data/REFERENCE.md +108 -57
  8. data/Rakefile +46 -54
  9. data/lib/haml/attribute_builder.rb +163 -0
  10. data/lib/haml/attribute_compiler.rb +215 -0
  11. data/lib/haml/attribute_parser.rb +144 -0
  12. data/lib/haml/buffer.rb +22 -132
  13. data/lib/haml/compiler.rb +87 -295
  14. data/lib/haml/engine.rb +25 -41
  15. data/lib/haml/error.rb +3 -0
  16. data/lib/haml/escapable.rb +49 -0
  17. data/lib/haml/exec.rb +33 -19
  18. data/lib/haml/filters.rb +18 -24
  19. data/lib/haml/generator.rb +41 -0
  20. data/lib/haml/helpers/action_view_extensions.rb +3 -2
  21. data/lib/haml/helpers/action_view_mods.rb +36 -58
  22. data/lib/haml/helpers/action_view_xss_mods.rb +1 -0
  23. data/lib/haml/helpers/safe_erubi_template.rb +27 -0
  24. data/lib/haml/helpers/safe_erubis_template.rb +4 -1
  25. data/lib/haml/helpers/xss_mods.rb +18 -12
  26. data/lib/haml/helpers.rb +133 -90
  27. data/lib/haml/options.rb +38 -47
  28. data/lib/haml/parser.rb +278 -216
  29. data/lib/haml/{template/plugin.rb → plugin.rb} +8 -15
  30. data/lib/haml/railtie.rb +21 -12
  31. data/lib/haml/sass_rails_filter.rb +17 -4
  32. data/lib/haml/template/options.rb +12 -2
  33. data/lib/haml/template.rb +12 -6
  34. data/lib/haml/temple_engine.rb +120 -0
  35. data/lib/haml/temple_line_counter.rb +29 -0
  36. data/lib/haml/util.rb +80 -199
  37. data/lib/haml/version.rb +2 -1
  38. data/lib/haml.rb +1 -0
  39. data/test/attribute_parser_test.rb +101 -0
  40. data/test/engine_test.rb +287 -176
  41. data/test/filters_test.rb +32 -19
  42. data/test/gemfiles/Gemfile.rails-4.0.x +9 -3
  43. data/test/gemfiles/Gemfile.rails-4.0.x.lock +87 -0
  44. data/test/gemfiles/Gemfile.rails-4.1.x +5 -0
  45. data/test/gemfiles/Gemfile.rails-4.2.x +5 -0
  46. data/test/gemfiles/Gemfile.rails-5.0.x +4 -0
  47. data/test/helper_test.rb +224 -112
  48. data/test/options_test.rb +22 -0
  49. data/test/parser_test.rb +71 -4
  50. data/test/results/bemit.xhtml +4 -0
  51. data/test/results/eval_suppressed.xhtml +4 -4
  52. data/test/results/helpers.xhtml +43 -41
  53. data/test/results/helpful.xhtml +6 -3
  54. data/test/results/just_stuff.xhtml +21 -20
  55. data/test/results/list.xhtml +9 -9
  56. data/test/results/nuke_inner_whitespace.xhtml +22 -22
  57. data/test/results/nuke_outer_whitespace.xhtml +84 -92
  58. data/test/results/original_engine.xhtml +17 -17
  59. data/test/results/partial_layout.xhtml +4 -3
  60. data/test/results/partial_layout_erb.xhtml +4 -3
  61. data/test/results/partials.xhtml +11 -10
  62. data/test/results/silent_script.xhtml +63 -63
  63. data/test/results/standard.xhtml +156 -159
  64. data/test/results/tag_parsing.xhtml +19 -19
  65. data/test/results/very_basic.xhtml +2 -2
  66. data/test/results/whitespace_handling.xhtml +77 -76
  67. data/test/template_test.rb +24 -56
  68. data/test/template_test_helper.rb +38 -0
  69. data/test/templates/bemit.haml +3 -0
  70. data/test/templates/just_stuff.haml +1 -0
  71. data/test/templates/standard_ugly.haml +1 -0
  72. data/test/templates/with_bom.haml +1 -0
  73. data/test/temple_line_counter_test.rb +40 -0
  74. data/test/test_helper.rb +26 -8
  75. data/test/util_test.rb +6 -47
  76. metadata +53 -43
  77. data/test/gemfiles/Gemfile.rails-3.0.x +0 -5
  78. data/test/gemfiles/Gemfile.rails-3.1.x +0 -6
  79. data/test/gemfiles/Gemfile.rails-3.2.x +0 -5
  80. data/test/haml-spec/LICENSE +0 -14
  81. data/test/haml-spec/README.md +0 -106
  82. data/test/haml-spec/lua_haml_spec.lua +0 -38
  83. data/test/haml-spec/perl_haml_test.pl +0 -81
  84. data/test/haml-spec/ruby_haml_test.rb +0 -23
  85. data/test/haml-spec/tests.json +0 -660
  86. data/test/templates/_av_partial_1_ugly.haml +0 -9
  87. data/test/templates/_av_partial_2_ugly.haml +0 -5
  88. data/test/templates/action_view_ugly.haml +0 -47
  89. data/test/templates/standard_ugly.haml +0 -43
@@ -1,59 +1,61 @@
1
1
  &&&&&&&&&&&
2
2
  <div>
3
- <p class='title'>Title</p>
4
- <p class='text'>
5
- Woah this is really crazy
6
- I mean wow,
7
- man.
8
- </p>
3
+ <p class='title'>Title</p>
4
+ <p class='text'>
5
+ Woah this is really crazy
6
+ I mean wow,
7
+ man.
8
+ </p>
9
9
  </div>
10
+
10
11
  <div>
11
- <p class='title'>Title</p>
12
- <p class='text'>
13
- Woah this is really crazy
14
- I mean wow,
15
- man.
16
- </p>
12
+ <p class='title'>Title</p>
13
+ <p class='text'>
14
+ Woah this is really crazy
15
+ I mean wow,
16
+ man.
17
+ </p>
17
18
  </div>
19
+
18
20
  <div>
19
- <p class='title'>Title</p>
20
- <p class='text'>
21
- Woah this is really crazy
22
- I mean wow,
23
- man.
24
- </p>
21
+ <p class='title'>Title</p>
22
+ <p class='text'>
23
+ Woah this is really crazy
24
+ I mean wow,
25
+ man.
26
+ </p>
25
27
  </div>
28
+
26
29
  <p>foo</p>
27
- <p>reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeally loooooooooooooooooong</p>
30
+ <p>reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeally loooooooooooooooooong</p>
28
31
  <div class='woah'>
29
- <div id='funky'>
30
- <div>
31
- <h1>Big!</h1>
32
- <p>Small</p>
33
- <!-- Invisible -->
34
- </div>
35
- <div class='dilly'>
36
- <p>foo</p>
37
- <h1>bar</h1>
38
- </div>
39
- </div>
40
- (<strong>parentheses!</strong>)
32
+ <div id='funky'>
33
+ <div>
34
+ <h1>Big!</h1>
35
+ <p>Small</p>
36
+ <!-- Invisible -->
37
+ </div>
38
+ <div class='dilly'>
39
+ <p>foo</p>
40
+ <h1>bar</h1>
41
+ </div>
42
+ </div>
43
+ (<strong>parentheses!</strong>)
41
44
  </div>
42
45
  *<span class='small'>Not really</span>
43
46
  click
44
47
  <a href='thing'>here</a>.
45
48
  <p>baz</p>
46
- <p>boom</p>
49
+ <p>boom</p>
50
+ foo
51
+ <li><a href='http://www.google.com'>google</a></li><p>
47
52
  foo
48
- <li><a href='http://www.google.com'>google</a></li>
49
- <p>
50
- foo
51
- <div>
52
- bar
53
- </div>
54
- boom
55
- baz
56
- boom, again
53
+ <div>
54
+ bar
55
+ </div>
56
+ boom
57
+ baz
58
+ boom, again
57
59
  </p>
58
60
  <table>
59
61
  <tr>
@@ -1,10 +1,13 @@
1
1
  <div class='article' id='article_1'>
2
- <h1>Hello</h1>
3
- <div>World</div>
2
+ <h1>Hello</h1>
3
+ <div>World</div>
4
4
  </div>
5
5
  <div class='article' id='id_article_1'>id</div>
6
6
  <div class='article class' id='article_1'>class</div>
7
7
  <div class='article class' id='id_article_1'>id class</div>
8
8
  <div class='article full' id='article_1'>boo</div>
9
9
  <div class='article full' id='article_1'>moo</div>
10
- <div class='article articleFull' id='article_1'>foo</div>
10
+ <div class='article articleFull' id='article_1'>foo</div>
11
+ <span>
12
+ Boo
13
+ </span>
@@ -6,7 +6,7 @@
6
6
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
7
7
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
8
8
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
9
- <strong apos="Foo's bar!">Boo!</strong>
9
+ <strong apos='Foo&#39;s bar!'>Boo!</strong>
10
10
  Embedded? false!
11
11
  Embedded? true!
12
12
  Embedded? true!
@@ -20,29 +20,30 @@ Embedded? one af"t"er another!
20
20
  stuff followed by whitespace
21
21
  <strong>block with whitespace</strong>
22
22
  <p>
23
- Escape
24
- - character
25
- %p foo
26
- yee\ha
23
+ Escape
24
+ - character
25
+ %p foo
26
+ yee\ha
27
+ don't lstrip me
27
28
  </p>
28
29
  <!-- Short comment -->
29
30
  <!--
30
- This is a block comment
31
- cool, huh?
32
- <strong>there can even be sub-tags!</strong>
33
- Or script!
31
+ This is a block comment
32
+ cool, huh?
33
+ <strong>there can even be sub-tags!</strong>
34
+ Or script!
34
35
  -->
35
36
  <p class=''>class attribute should appear!</p>
36
37
  <p>this attribute shouldn't appear</p>
37
38
  <!--[if lte IE6]> conditional comment! <![endif]-->
38
39
  <!--[if gte IE7]>
39
- <p>Block conditional comment</p>
40
- <div>
41
- <h1>Cool, eh?</h1>
42
- </div>
40
+ <p>Block conditional comment</p>
41
+ <div>
42
+ <h1>Cool, eh?</h1>
43
+ </div>
43
44
  <![endif]-->
44
45
  <!--[if gte IE5.2]>
45
- Woah a period.
46
+ Woah a period.
46
47
  <![endif]-->
47
48
  testtest
48
49
  <br />
@@ -52,7 +53,7 @@ testtest
52
53
  <link />
53
54
  <script>Inline content</script>
54
55
  <br>
55
- Nested content
56
+ Nested content
56
57
  </br>
57
58
  <p class='article bar foo' id='article_1'>Blah</p>
58
59
  <p class='article foo' id='article_1'>Blah</p>
@@ -60,11 +61,11 @@ testtest
60
61
  <p class='article quux qux' id='article_1'>Blump</p>
61
62
  <p class='article' id='foo_bar_baz_article_1'>Whee</p>
62
63
  Woah inner quotes
63
- <p class='dynamic_quote' dyn='3' quotes="single '"></p>
64
+ <p class='dynamic_quote' dyn='3' quotes='single &#39;'></p>
64
65
  <p class='dynamic_self_closing' dyn='3' />
65
66
  <body>
66
- hello
67
- <div>
68
- <img />
69
- </div>
67
+ hello
68
+ <div>
69
+ <img />
70
+ </div>
70
71
  </body>
@@ -1,12 +1,12 @@
1
1
  !Not a Doctype!
2
2
  <ul>
3
- <li>a</li>
4
- <li>b</li>
5
- <li>c</li>
6
- <li>d</li>
7
- <li>e</li>
8
- <li>f</li>
9
- <li>g</li>
10
- <li>h</li>
11
- <li>i</li>
3
+ <li>a</li>
4
+ <li>b</li>
5
+ <li>c</li>
6
+ <li>d</li>
7
+ <li>e</li>
8
+ <li>f</li>
9
+ <li>g</li>
10
+ <li>h</li>
11
+ <li>i</li>
12
12
  </ul>
@@ -1,40 +1,40 @@
1
1
  <p>
2
- <q>Foo</q>
2
+ <q>Foo</q>
3
3
  </p>
4
4
  <p>
5
- <q a='2'>Foo</q>
5
+ <q a='2'>Foo</q>
6
6
  </p>
7
7
  <p>
8
- <q>Foo
9
- Bar</q>
8
+ <q>Foo
9
+ Bar</q>
10
10
  </p>
11
11
  <p>
12
- <q a='2'>Foo
13
- Bar</q>
12
+ <q a='2'>Foo
13
+ Bar</q>
14
14
  </p>
15
15
  <p>
16
- <q>Foo
17
- Bar</q>
16
+ <q>Foo
17
+ Bar</q>
18
18
  </p>
19
19
  <p>
20
- <q a='2'>Foo
21
- Bar</q>
20
+ <q a='2'>Foo
21
+ Bar</q>
22
22
  </p>
23
23
  <p>
24
- <q><div>
25
- Foo
26
- Bar
27
- </div></q>
24
+ <q><div>
25
+ Foo
26
+ Bar
27
+ </div></q>
28
28
  </p>
29
29
  <p>
30
- <q a='2'><div>
31
- Foo
32
- Bar
33
- </div></q>
30
+ <q a='2'><div>
31
+ Foo
32
+ Bar
33
+ </div></q>
34
34
  </p>
35
35
  <p>
36
- <q>foo</q>
37
- <q a='2'>
38
- bar
39
- </q>
36
+ <q>foo</q>
37
+ <q a='2'>
38
+ bar
39
+ </q>
40
40
  </p>
@@ -1,148 +1,140 @@
1
1
  <p>
2
- <p><q>
3
- Foo
4
- </q></p>
2
+ <p><q>
3
+ Foo
4
+ </q></p>
5
5
  </p>
6
6
  <p>
7
- <p><q a='2'>
8
- Foo
9
- </q></p>
7
+ <p><q a='2'>
8
+ Foo
9
+ </q></p>
10
10
  </p>
11
11
  <p>
12
- <p><q>Foo</q></p>
12
+ <p><q>Foo</q></p>
13
13
  </p>
14
14
  <p>
15
- <p><q a='2'>Foo</q></p>
15
+ <p><q a='2'>Foo</q></p>
16
16
  </p>
17
17
  <p>
18
- <p><q>
19
- Foo
20
- </q></p>
18
+ <p><q>
19
+ Foo
20
+ </q></p>
21
21
  </p>
22
22
  <p>
23
- <p><q a='2'>
24
- Foo
25
- </q></p>
23
+ <p><q a='2'>
24
+ Foo
25
+ </q></p>
26
26
  </p>
27
27
  <p>
28
- <p><q>Foo</q></p>
28
+ <p><q>Foo</q></p>
29
29
  </p>
30
30
  <p>
31
- <p><q a='2'>Foo</q></p>
31
+ <p><q a='2'>Foo</q></p>
32
32
  </p>
33
33
  <p>
34
- <p><q>
35
- Foo
36
- Bar
37
- </q></p>
34
+ <p><q>
35
+ Foo
36
+ Bar
37
+ </q></p>
38
38
  </p>
39
39
  <p>
40
- <p><q a='2'>
41
- Foo
42
- Bar
43
- </q></p>
40
+ <p><q a='2'>
41
+ Foo
42
+ Bar
43
+ </q></p>
44
44
  </p>
45
45
  <p>
46
- <p><q>
47
- Foo
48
- Bar
49
- </q></p>
46
+ <p><q>Foo
47
+ Bar</q></p>
50
48
  </p>
51
49
  <p>
52
- <p><q a='2'>
53
- Foo
54
- Bar
55
- </q></p>
50
+ <p><q a='2'>Foo
51
+ Bar</q></p>
56
52
  </p>
57
53
  <p>
58
- <p>
59
- foo<q>
60
- Foo
61
- </q>bar
62
- </p>
54
+ <p>
55
+ foo<q>
56
+ Foo
57
+ </q>bar
58
+ </p>
63
59
  </p>
64
60
  <p>
65
- <p>
66
- foo<q a='2'>
67
- Foo
68
- </q>bar
69
- </p>
61
+ <p>
62
+ foo<q a='2'>
63
+ Foo
64
+ </q>bar
70
65
  </p>
66
+ </p>
67
+ <p>
71
68
  <p>
72
- <p>
73
- foo<q>Foo</q>bar
74
- </p>
69
+ foo<q>Foo</q>bar
70
+ </p>
75
71
  </p>
76
72
  <p>
77
- <p>
78
- foo<q a='2'>Foo</q>bar
79
- </p>
73
+ <p>
74
+ foo<q a='2'>Foo</q>bar
75
+ </p>
80
76
  </p>
81
77
  <p>
82
- <p>
83
- foo<q>
84
- Foo
85
- </q>bar
86
- </p>
78
+ <p>
79
+ foo<q>
80
+ Foo
81
+ </q>bar
87
82
  </p>
83
+ </p>
84
+ <p>
88
85
  <p>
89
- <p>
90
- foo<q a='2'>
91
- Foo
92
- </q>bar
93
- </p>
86
+ foo<q a='2'>
87
+ Foo
88
+ </q>bar
89
+ </p>
94
90
  </p>
95
91
  <p>
96
- <p>
97
- foo<q>Foo</q>bar
98
- </p>
92
+ <p>
93
+ foo<q>Foo</q>bar
94
+ </p>
99
95
  </p>
100
96
  <p>
101
- <p>
102
- foo<q a='2'>Foo</q>bar
103
- </p>
97
+ <p>
98
+ foo<q a='2'>Foo</q>bar
104
99
  </p>
100
+ </p>
101
+ <p>
105
102
  <p>
106
- <p>
107
- foo<q>
108
- Foo
109
- Bar
110
- </q>bar
111
- </p>
103
+ foo<q>
104
+ Foo
105
+ Bar
106
+ </q>bar
107
+ </p>
112
108
  </p>
113
109
  <p>
114
- <p>
115
- foo<q a='2'>
116
- Foo
117
- Bar
118
- </q>bar
119
- </p>
110
+ <p>
111
+ foo<q a='2'>
112
+ Foo
113
+ Bar
114
+ </q>bar
115
+ </p>
120
116
  </p>
121
117
  <p>
122
- <p>
123
- foo<q>
124
- Foo
125
- Bar
126
- </q>bar
127
- </p>
118
+ <p>
119
+ foo<q>Foo
120
+ Bar</q>bar
128
121
  </p>
122
+ </p>
123
+ <p>
129
124
  <p>
130
- <p>
131
- foo<q a='2'>
132
- Foo
133
- Bar
134
- </q>bar
135
- </p>
125
+ foo<q a='2'>Foo
126
+ Bar</q>bar
127
+ </p>
136
128
  </p>
137
129
  <p>
138
- <p><q></q></p>
130
+ <p><q></q></p>
139
131
  </p>
140
132
  <p>
141
- <p><q /></p>
133
+ <p><q /></p>
142
134
  </p>
143
135
  <p>
144
- <p><q a='2'></q></p>
136
+ <p><q a='2'></q></p>
145
137
  </p>
146
138
  <p>
147
- <p><q a='2' /></p>
139
+ <p><q a='2' /></p>
148
140
  </p>
@@ -1,20 +1,20 @@
1
1
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
2
  <html>
3
- <head>
4
- <title>Stop. haml time</title>
5
- <div id='content'>
6
- <h1>This is a title!</h1>
7
- <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>
8
- <p class='foo'>Cigarettes!</p>
9
- <h2>Man alive!</h2>
10
- <ul class='things'>
11
- <li>Slippers</li>
12
- <li>Shoes</li>
13
- <li>Bathrobe</li>
14
- <li>Coffee</li>
15
- </ul>
16
- <pre>This is some text that's in a pre block!
17
- Let's see what happens when it's rendered! What about now, since we're on a new line?</pre>
18
- </div>
19
- </head>
3
+ <head>
4
+ <title>Stop. haml time</title>
5
+ <div id='content'>
6
+ <h1>This is a title!</h1>
7
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>
8
+ <p class='foo'>Cigarettes!</p>
9
+ <h2>Man alive!</h2>
10
+ <ul class='things'>
11
+ <li>Slippers</li>
12
+ <li>Shoes</li>
13
+ <li>Bathrobe</li>
14
+ <li>Coffee</li>
15
+ </ul>
16
+ <pre>This is some text that's in a pre block!
17
+ Let's see what happens when it's rendered! What about now, since we're on a new line?</pre>
18
+ </div>
19
+ </head>
20
20
  </html>
@@ -1,5 +1,6 @@
1
1
  <h1>Partial layout used with for block:</h1>
2
2
  <div class='partial-layout'>
3
- <h2>This is inside a partial layout</h2>
4
- <p>Some content within a layout</p>
5
- </div>
3
+ <h2>This is inside a partial layout</h2>
4
+ <p>Some content within a layout</p>
5
+
6
+ </div>
@@ -1,5 +1,6 @@
1
1
  <h1>Partial layout used with for block:</h1>
2
2
  <div class='partial-layout'>
3
- <h2>This is inside a partial layout</h2>
4
- Some content within a layout
5
- </div>
3
+ <h2>This is inside a partial layout</h2>
4
+ Some content within a layout
5
+
6
+ </div>
@@ -1,21 +1,22 @@
1
1
  <p>
2
- @foo =
3
- value one
2
+ @foo =
3
+ value one
4
4
  </p>
5
5
  <p>
6
- @foo =
7
- value two
6
+ @foo =
7
+ value two
8
8
  </p>
9
9
  <p>
10
- @foo =
11
- value two
10
+ @foo =
11
+ value two
12
12
  </p>
13
13
  Toplevel? false
14
14
  <p>
15
- @foo =
16
- value three
15
+ @foo =
16
+ value three
17
17
  </p>
18
+
18
19
  <p>
19
- @foo =
20
- value three
20
+ @foo =
21
+ value three
21
22
  </p>