haml 4.0.7 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/CHANGELOG.md +42 -4
- data/FAQ.md +4 -14
- data/MIT-LICENSE +1 -1
- data/README.md +85 -42
- data/REFERENCE.md +108 -57
- data/Rakefile +46 -54
- data/lib/haml/attribute_builder.rb +163 -0
- data/lib/haml/attribute_compiler.rb +215 -0
- data/lib/haml/attribute_parser.rb +144 -0
- data/lib/haml/buffer.rb +22 -132
- data/lib/haml/compiler.rb +87 -295
- data/lib/haml/engine.rb +25 -41
- data/lib/haml/error.rb +3 -0
- data/lib/haml/escapable.rb +49 -0
- data/lib/haml/exec.rb +33 -19
- data/lib/haml/filters.rb +18 -24
- data/lib/haml/generator.rb +41 -0
- data/lib/haml/helpers/action_view_extensions.rb +3 -2
- data/lib/haml/helpers/action_view_mods.rb +36 -58
- data/lib/haml/helpers/action_view_xss_mods.rb +1 -0
- data/lib/haml/helpers/safe_erubi_template.rb +27 -0
- data/lib/haml/helpers/safe_erubis_template.rb +4 -1
- data/lib/haml/helpers/xss_mods.rb +18 -12
- data/lib/haml/helpers.rb +133 -90
- data/lib/haml/options.rb +38 -47
- data/lib/haml/parser.rb +278 -216
- data/lib/haml/{template/plugin.rb → plugin.rb} +8 -15
- data/lib/haml/railtie.rb +21 -12
- data/lib/haml/sass_rails_filter.rb +17 -4
- data/lib/haml/template/options.rb +12 -2
- data/lib/haml/template.rb +12 -6
- data/lib/haml/temple_engine.rb +120 -0
- data/lib/haml/temple_line_counter.rb +29 -0
- data/lib/haml/util.rb +80 -199
- data/lib/haml/version.rb +2 -1
- data/lib/haml.rb +1 -0
- data/test/attribute_parser_test.rb +101 -0
- data/test/engine_test.rb +287 -176
- data/test/filters_test.rb +32 -19
- data/test/gemfiles/Gemfile.rails-4.0.x +9 -3
- data/test/gemfiles/Gemfile.rails-4.0.x.lock +87 -0
- data/test/gemfiles/Gemfile.rails-4.1.x +5 -0
- data/test/gemfiles/Gemfile.rails-4.2.x +5 -0
- data/test/gemfiles/Gemfile.rails-5.0.x +4 -0
- data/test/helper_test.rb +224 -112
- data/test/options_test.rb +22 -0
- data/test/parser_test.rb +71 -4
- data/test/results/bemit.xhtml +4 -0
- data/test/results/eval_suppressed.xhtml +4 -4
- data/test/results/helpers.xhtml +43 -41
- data/test/results/helpful.xhtml +6 -3
- data/test/results/just_stuff.xhtml +21 -20
- data/test/results/list.xhtml +9 -9
- data/test/results/nuke_inner_whitespace.xhtml +22 -22
- data/test/results/nuke_outer_whitespace.xhtml +84 -92
- data/test/results/original_engine.xhtml +17 -17
- data/test/results/partial_layout.xhtml +4 -3
- data/test/results/partial_layout_erb.xhtml +4 -3
- data/test/results/partials.xhtml +11 -10
- data/test/results/silent_script.xhtml +63 -63
- data/test/results/standard.xhtml +156 -159
- data/test/results/tag_parsing.xhtml +19 -19
- data/test/results/very_basic.xhtml +2 -2
- data/test/results/whitespace_handling.xhtml +77 -76
- data/test/template_test.rb +24 -56
- data/test/template_test_helper.rb +38 -0
- data/test/templates/bemit.haml +3 -0
- data/test/templates/just_stuff.haml +1 -0
- data/test/templates/standard_ugly.haml +1 -0
- data/test/templates/with_bom.haml +1 -0
- data/test/temple_line_counter_test.rb +40 -0
- data/test/test_helper.rb +26 -8
- data/test/util_test.rb +6 -47
- metadata +53 -43
- data/test/gemfiles/Gemfile.rails-3.0.x +0 -5
- data/test/gemfiles/Gemfile.rails-3.1.x +0 -6
- data/test/gemfiles/Gemfile.rails-3.2.x +0 -5
- data/test/haml-spec/LICENSE +0 -14
- data/test/haml-spec/README.md +0 -106
- data/test/haml-spec/lua_haml_spec.lua +0 -38
- data/test/haml-spec/perl_haml_test.pl +0 -81
- data/test/haml-spec/ruby_haml_test.rb +0 -23
- data/test/haml-spec/tests.json +0 -660
- data/test/templates/_av_partial_1_ugly.haml +0 -9
- data/test/templates/_av_partial_2_ugly.haml +0 -5
- data/test/templates/action_view_ugly.haml +0 -47
- data/test/templates/standard_ugly.haml +0 -43
data/test/results/helpers.xhtml
CHANGED
@@ -1,59 +1,61 @@
|
|
1
1
|
&&&&&&&&&&&
|
2
2
|
<div>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
30
|
+
<p>reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeally loooooooooooooooooong</p>
|
28
31
|
<div class='woah'>
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
-
|
49
|
+
<p>boom</p>
|
50
|
+
foo
|
51
|
+
<li><a href='http://www.google.com'>google</a></li><p>
|
47
52
|
foo
|
48
|
-
<
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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>
|
data/test/results/helpful.xhtml
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
<div class='article' id='article_1'>
|
2
|
-
|
3
|
-
|
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=
|
9
|
+
<strong apos='Foo'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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
-
|
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
|
-
|
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=
|
64
|
+
<p class='dynamic_quote' dyn='3' quotes='single ''></p>
|
64
65
|
<p class='dynamic_self_closing' dyn='3' />
|
65
66
|
<body>
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
hello
|
68
|
+
<div>
|
69
|
+
<img />
|
70
|
+
</div>
|
70
71
|
</body>
|
data/test/results/list.xhtml
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
!Not a Doctype!
|
2
2
|
<ul>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
2
|
+
<q>Foo</q>
|
3
3
|
</p>
|
4
4
|
<p>
|
5
|
-
|
5
|
+
<q a='2'>Foo</q>
|
6
6
|
</p>
|
7
7
|
<p>
|
8
|
-
|
9
|
-
|
8
|
+
<q>Foo
|
9
|
+
Bar</q>
|
10
10
|
</p>
|
11
11
|
<p>
|
12
|
-
|
13
|
-
|
12
|
+
<q a='2'>Foo
|
13
|
+
Bar</q>
|
14
14
|
</p>
|
15
15
|
<p>
|
16
|
-
|
17
|
-
|
16
|
+
<q>Foo
|
17
|
+
Bar</q>
|
18
18
|
</p>
|
19
19
|
<p>
|
20
|
-
|
21
|
-
|
20
|
+
<q a='2'>Foo
|
21
|
+
Bar</q>
|
22
22
|
</p>
|
23
23
|
<p>
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
<q><div>
|
25
|
+
Foo
|
26
|
+
Bar
|
27
|
+
</div></q>
|
28
28
|
</p>
|
29
29
|
<p>
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
<q a='2'><div>
|
31
|
+
Foo
|
32
|
+
Bar
|
33
|
+
</div></q>
|
34
34
|
</p>
|
35
35
|
<p>
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
<q>foo</q>
|
37
|
+
<q a='2'>
|
38
|
+
bar
|
39
|
+
</q>
|
40
40
|
</p>
|
@@ -1,148 +1,140 @@
|
|
1
1
|
<p>
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
<p><q>
|
3
|
+
Foo
|
4
|
+
</q></p>
|
5
5
|
</p>
|
6
6
|
<p>
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
<p><q a='2'>
|
8
|
+
Foo
|
9
|
+
</q></p>
|
10
10
|
</p>
|
11
11
|
<p>
|
12
|
-
|
12
|
+
<p><q>Foo</q></p>
|
13
13
|
</p>
|
14
14
|
<p>
|
15
|
-
|
15
|
+
<p><q a='2'>Foo</q></p>
|
16
16
|
</p>
|
17
17
|
<p>
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
<p><q>
|
19
|
+
Foo
|
20
|
+
</q></p>
|
21
21
|
</p>
|
22
22
|
<p>
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
<p><q a='2'>
|
24
|
+
Foo
|
25
|
+
</q></p>
|
26
26
|
</p>
|
27
27
|
<p>
|
28
|
-
|
28
|
+
<p><q>Foo</q></p>
|
29
29
|
</p>
|
30
30
|
<p>
|
31
|
-
|
31
|
+
<p><q a='2'>Foo</q></p>
|
32
32
|
</p>
|
33
33
|
<p>
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
<p><q>
|
35
|
+
Foo
|
36
|
+
Bar
|
37
|
+
</q></p>
|
38
38
|
</p>
|
39
39
|
<p>
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
<p><q a='2'>
|
41
|
+
Foo
|
42
|
+
Bar
|
43
|
+
</q></p>
|
44
44
|
</p>
|
45
45
|
<p>
|
46
|
-
|
47
|
-
|
48
|
-
Bar
|
49
|
-
</q></p>
|
46
|
+
<p><q>Foo
|
47
|
+
Bar</q></p>
|
50
48
|
</p>
|
51
49
|
<p>
|
52
|
-
|
53
|
-
|
54
|
-
Bar
|
55
|
-
</q></p>
|
50
|
+
<p><q a='2'>Foo
|
51
|
+
Bar</q></p>
|
56
52
|
</p>
|
57
53
|
<p>
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
54
|
+
<p>
|
55
|
+
foo<q>
|
56
|
+
Foo
|
57
|
+
</q>bar
|
58
|
+
</p>
|
63
59
|
</p>
|
64
60
|
<p>
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
-
|
73
|
-
|
74
|
-
</p>
|
69
|
+
foo<q>Foo</q>bar
|
70
|
+
</p>
|
75
71
|
</p>
|
76
72
|
<p>
|
77
|
-
|
78
|
-
|
79
|
-
|
73
|
+
<p>
|
74
|
+
foo<q a='2'>Foo</q>bar
|
75
|
+
</p>
|
80
76
|
</p>
|
81
77
|
<p>
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
</p>
|
78
|
+
<p>
|
79
|
+
foo<q>
|
80
|
+
Foo
|
81
|
+
</q>bar
|
87
82
|
</p>
|
83
|
+
</p>
|
84
|
+
<p>
|
88
85
|
<p>
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
</p>
|
86
|
+
foo<q a='2'>
|
87
|
+
Foo
|
88
|
+
</q>bar
|
89
|
+
</p>
|
94
90
|
</p>
|
95
91
|
<p>
|
96
|
-
|
97
|
-
|
98
|
-
|
92
|
+
<p>
|
93
|
+
foo<q>Foo</q>bar
|
94
|
+
</p>
|
99
95
|
</p>
|
100
96
|
<p>
|
101
|
-
|
102
|
-
|
103
|
-
</p>
|
97
|
+
<p>
|
98
|
+
foo<q a='2'>Foo</q>bar
|
104
99
|
</p>
|
100
|
+
</p>
|
101
|
+
<p>
|
105
102
|
<p>
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
</p>
|
103
|
+
foo<q>
|
104
|
+
Foo
|
105
|
+
Bar
|
106
|
+
</q>bar
|
107
|
+
</p>
|
112
108
|
</p>
|
113
109
|
<p>
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
110
|
+
<p>
|
111
|
+
foo<q a='2'>
|
112
|
+
Foo
|
113
|
+
Bar
|
114
|
+
</q>bar
|
115
|
+
</p>
|
120
116
|
</p>
|
121
117
|
<p>
|
122
|
-
|
123
|
-
|
124
|
-
|
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
|
-
|
131
|
-
|
132
|
-
|
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
|
-
|
130
|
+
<p><q></q></p>
|
139
131
|
</p>
|
140
132
|
<p>
|
141
|
-
|
133
|
+
<p><q /></p>
|
142
134
|
</p>
|
143
135
|
<p>
|
144
|
-
|
136
|
+
<p><q a='2'></q></p>
|
145
137
|
</p>
|
146
138
|
<p>
|
147
|
-
|
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
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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>
|
data/test/results/partials.xhtml
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
<p>
|
2
|
-
|
3
|
-
|
2
|
+
@foo =
|
3
|
+
value one
|
4
4
|
</p>
|
5
5
|
<p>
|
6
|
-
|
7
|
-
|
6
|
+
@foo =
|
7
|
+
value two
|
8
8
|
</p>
|
9
9
|
<p>
|
10
|
-
|
11
|
-
|
10
|
+
@foo =
|
11
|
+
value two
|
12
12
|
</p>
|
13
13
|
Toplevel? false
|
14
14
|
<p>
|
15
|
-
|
16
|
-
|
15
|
+
@foo =
|
16
|
+
value three
|
17
17
|
</p>
|
18
|
+
|
18
19
|
<p>
|
19
|
-
|
20
|
-
|
20
|
+
@foo =
|
21
|
+
value three
|
21
22
|
</p>
|