haml 1.8.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of haml might be problematic. Click here for more details.
- data/FAQ +138 -0
- data/MIT-LICENSE +1 -1
- data/{README → README.rdoc} +66 -3
- data/Rakefile +111 -147
- data/VERSION +1 -1
- data/bin/css2sass +0 -0
- data/bin/haml +0 -0
- data/bin/html2haml +0 -0
- data/bin/sass +0 -0
- data/init.rb +6 -1
- data/lib/haml.rb +464 -201
- data/lib/haml/buffer.rb +117 -63
- data/lib/haml/engine.rb +63 -44
- data/lib/haml/error.rb +16 -6
- data/lib/haml/exec.rb +37 -7
- data/lib/haml/filters.rb +213 -68
- data/lib/haml/helpers.rb +95 -60
- data/lib/haml/helpers/action_view_extensions.rb +1 -1
- data/lib/haml/helpers/action_view_mods.rb +54 -6
- data/lib/haml/html.rb +6 -6
- data/lib/haml/precompiler.rb +254 -133
- data/lib/haml/template.rb +3 -6
- data/lib/haml/template/patch.rb +9 -2
- data/lib/haml/template/plugin.rb +52 -23
- data/lib/sass.rb +157 -12
- data/lib/sass/constant.rb +22 -22
- data/lib/sass/constant/color.rb +13 -13
- data/lib/sass/constant/literal.rb +7 -7
- data/lib/sass/constant/number.rb +9 -9
- data/lib/sass/constant/operation.rb +4 -4
- data/lib/sass/constant/string.rb +3 -3
- data/lib/sass/css.rb +104 -31
- data/lib/sass/engine.rb +120 -39
- data/lib/sass/error.rb +1 -1
- data/lib/sass/plugin.rb +14 -3
- data/lib/sass/plugin/merb.rb +6 -2
- data/lib/sass/tree/attr_node.rb +5 -5
- data/lib/sass/tree/directive_node.rb +2 -7
- data/lib/sass/tree/node.rb +1 -12
- data/lib/sass/tree/rule_node.rb +39 -31
- data/lib/sass/tree/value_node.rb +1 -1
- data/test/benchmark.rb +67 -80
- data/test/haml/engine_test.rb +284 -84
- data/test/haml/helper_test.rb +51 -15
- data/test/haml/results/content_for_layout.xhtml +1 -2
- data/test/haml/results/eval_suppressed.xhtml +2 -4
- data/test/haml/results/filters.xhtml +44 -15
- data/test/haml/results/helpers.xhtml +2 -3
- data/test/haml/results/just_stuff.xhtml +2 -6
- data/test/haml/results/nuke_inner_whitespace.xhtml +34 -0
- data/test/haml/results/nuke_outer_whitespace.xhtml +148 -0
- data/test/haml/results/original_engine.xhtml +3 -7
- data/test/haml/results/partials.xhtml +1 -0
- data/test/haml/results/tag_parsing.xhtml +1 -6
- data/test/haml/results/very_basic.xhtml +2 -4
- data/test/haml/results/whitespace_handling.xhtml +13 -21
- data/test/haml/template_test.rb +8 -15
- data/test/haml/templates/_partial.haml +1 -0
- data/test/haml/templates/filters.haml +48 -7
- data/test/haml/templates/just_stuff.haml +1 -2
- data/test/haml/templates/nuke_inner_whitespace.haml +26 -0
- data/test/haml/templates/nuke_outer_whitespace.haml +144 -0
- data/test/haml/templates/tag_parsing.haml +0 -3
- data/test/haml/test_helper.rb +15 -0
- data/test/sass/engine_test.rb +80 -34
- data/test/sass/plugin_test.rb +1 -1
- data/test/sass/results/import.css +2 -2
- data/test/sass/results/mixins.css +95 -0
- data/test/sass/results/multiline.css +24 -0
- data/test/sass/templates/import.sass +4 -1
- data/test/sass/templates/importee.sass +4 -0
- data/test/sass/templates/mixins.sass +76 -0
- data/test/sass/templates/multiline.sass +20 -0
- metadata +65 -51
- data/lib/haml/util.rb +0 -18
- data/test/haml/runner.rb +0 -16
- data/test/profile.rb +0 -65
data/test/haml/helper_test.rb
CHANGED
@@ -1,20 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'active_support'
|
5
|
-
require 'action_controller'
|
6
|
-
require 'action_view'
|
7
|
-
|
8
|
-
require 'test/unit'
|
9
|
-
require File.dirname(__FILE__) + '/../../lib/haml'
|
2
|
+
require File.dirname(__FILE__) + '/test_helper'
|
10
3
|
require 'haml/template'
|
11
4
|
|
12
5
|
class HelperTest < Test::Unit::TestCase
|
13
6
|
include Haml::Helpers
|
7
|
+
Post = Struct.new('Post', :body)
|
14
8
|
|
15
9
|
def setup
|
16
10
|
@base = ActionView::Base.new
|
17
11
|
@base.controller = ActionController::Base.new
|
12
|
+
@base.instance_variable_set('@post', Post.new("Foo bar\nbaz"))
|
18
13
|
end
|
19
14
|
|
20
15
|
def render(text, options = {})
|
@@ -27,14 +22,14 @@ class HelperTest < Test::Unit::TestCase
|
|
27
22
|
end
|
28
23
|
|
29
24
|
def test_flatten
|
30
|
-
assert_equal(
|
25
|
+
assert_equal("FooBar", flatten("FooBar"))
|
31
26
|
|
32
|
-
assert_equal(flatten("Foo\rBar")
|
27
|
+
assert_equal("FooBar", flatten("Foo\rBar"))
|
33
28
|
|
34
|
-
assert_equal(
|
29
|
+
assert_equal("Foo
Bar", flatten("Foo\nBar"))
|
35
30
|
|
36
|
-
assert_equal(
|
37
|
-
|
31
|
+
assert_equal("Hello
World!
YOU ARE FLAT?
OMGZ!",
|
32
|
+
flatten("Hello\nWorld!\nYOU ARE \rFLAT?\n\rOMGZ!"))
|
38
33
|
end
|
39
34
|
|
40
35
|
def test_list_of_should_render_correctly
|
@@ -85,10 +80,33 @@ class HelperTest < Test::Unit::TestCase
|
|
85
80
|
should_be = "<form action=\"foo\" method=\"post\">\n <p>bar</p>\n <strong>baz</strong>\n</form>\n"
|
86
81
|
assert_equal(should_be, result)
|
87
82
|
end
|
83
|
+
|
84
|
+
def test_text_area
|
85
|
+
assert_equal(%(<textarea id="body" name="body">Foo
Bar
 Baz
 Boom</textarea>\n),
|
86
|
+
render('= text_area_tag "body", "Foo\nBar\n Baz\n Boom"', :action_view))
|
87
|
+
|
88
|
+
assert_equal(%(<textarea cols="40" id="post_body" name="post[body]" rows="20">Foo bar
baz</textarea>\n),
|
89
|
+
render('= text_area :post, :body', :action_view))
|
90
|
+
|
91
|
+
assert_equal(%(<pre>Foo bar
 baz</pre>\n),
|
92
|
+
render('= content_tag "pre", "Foo bar\n baz"', :action_view))
|
93
|
+
end
|
88
94
|
|
89
95
|
def test_capture_haml
|
90
96
|
assert_equal("\"<p>13</p>\\n\"\n", render("- foo = capture_haml(13) do |a|\n %p= a\n= foo.dump"))
|
91
97
|
end
|
98
|
+
|
99
|
+
def test_haml_tag_attribute_html_escaping
|
100
|
+
assert_equal("<p id='foo&bar'>baz</p>\n", render("%p{:id => 'foo&bar'} baz", :escape_html => true))
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_haml_tag_autoclosed_tags_are_closed
|
104
|
+
assert_equal("<br class='foo' />\n", render("- haml_tag :br, :class => 'foo'"))
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_haml_tag_non_autoclosed_tags_arent_closed
|
108
|
+
assert_equal("<p>\n</p>\n", render("- haml_tag :p"))
|
109
|
+
end
|
92
110
|
|
93
111
|
def test_is_haml
|
94
112
|
assert(!ActionView::Base.new.is_haml?)
|
@@ -123,12 +141,12 @@ class HelperTest < Test::Unit::TestCase
|
|
123
141
|
end
|
124
142
|
|
125
143
|
def test_find_and_preserve_with_block
|
126
|
-
assert_equal("<pre
|
144
|
+
assert_equal("<pre>Foo
Bar</pre>\nFoo\nBar\n",
|
127
145
|
render("= find_and_preserve do\n %pre\n Foo\n Bar\n Foo\n Bar"))
|
128
146
|
end
|
129
147
|
|
130
148
|
def test_preserve_with_block
|
131
|
-
assert_equal("<pre
|
149
|
+
assert_equal("<pre>Foo
Bar</pre>
Foo
Bar\n",
|
132
150
|
render("= preserve do\n %pre\n Foo\n Bar\n Foo\n Bar"))
|
133
151
|
end
|
134
152
|
|
@@ -147,5 +165,23 @@ class HelperTest < Test::Unit::TestCase
|
|
147
165
|
|
148
166
|
assert_equal("<p attr='val'>\n Blah\n</p>\n", result)
|
149
167
|
end
|
168
|
+
|
169
|
+
def test_non_haml
|
170
|
+
assert_equal("false\n", render("= non_haml { is_haml? }"))
|
171
|
+
end
|
172
|
+
|
173
|
+
class ActsLikeTag
|
174
|
+
# We want to be able to have people include monkeypatched ActionView helpers
|
175
|
+
# without redefining is_haml?.
|
176
|
+
# This is accomplished via Object#is_haml?, and this is a test for it.
|
177
|
+
include ActionView::Helpers::TagHelper
|
178
|
+
def to_s
|
179
|
+
content_tag :p, 'some tag content'
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_random_class_includes_tag_helper
|
184
|
+
assert_equal "<p>some tag content</p>", ActsLikeTag.new.to_s
|
185
|
+
end
|
150
186
|
end
|
151
187
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<style>
|
2
2
|
p {
|
3
3
|
border-style: dotted;
|
4
|
-
border-width:
|
4
|
+
border-width: 22px;
|
5
5
|
border-color: #ff00ff; }
|
6
6
|
|
7
7
|
h1 {
|
@@ -11,9 +11,7 @@ TESTING HAHAHAHA!
|
|
11
11
|
<h1>Foo</h1>
|
12
12
|
|
13
13
|
|
14
|
-
<pre><code>This is preformatted
|
15
|
-
Look at that!
|
16
|
-
Wowie-zowie!</code></pre>
|
14
|
+
<pre><code>This is preformatted!
Look at that!
Wowie-zowie!</code></pre>
|
17
15
|
|
18
16
|
|
19
17
|
<p><strong>boldilicious!</strong></p>
|
@@ -21,31 +19,60 @@ Wowie-zowie!</code></pre>
|
|
21
19
|
|
22
20
|
|
23
21
|
<p><em>pretty much the same as above</em></p>
|
22
|
+
<p>
|
23
|
+
<script type='text/javascript'>
|
24
|
+
//<![CDATA[
|
25
|
+
function newline(str) {
|
26
|
+
return "\n" + str;
|
27
|
+
}
|
28
|
+
//]]>
|
29
|
+
</script>
|
30
|
+
</p>
|
24
31
|
This
|
25
32
|
Is
|
26
33
|
Plain
|
27
34
|
Text
|
28
35
|
%strong right?
|
36
|
+
#{not interpolated}
|
37
|
+
\3
|
38
|
+
\#{also not}
|
39
|
+
\\
|
40
|
+
<p>
|
41
|
+
<pre>This pre is pretty deeply
 nested.
 Does interpolation work?
|
42
|
+
This one is, too.
Nested, that is.
</pre>
|
43
|
+
</p>
|
44
|
+
<ul>
|
45
|
+
|
46
|
+
<li>a</li>
|
47
|
+
|
48
|
+
<li>b</li>
|
49
|
+
|
50
|
+
<li>c</li>
|
29
51
|
|
30
|
-
|
52
|
+
<li>d</li>
|
31
53
|
|
32
|
-
|
54
|
+
<li>e</li>
|
33
55
|
|
34
|
-
|
56
|
+
<li>f</li>
|
35
57
|
|
36
|
-
|
58
|
+
<li>g</li>
|
37
59
|
|
38
|
-
|
60
|
+
<li>h</li>
|
39
61
|
|
40
|
-
|
62
|
+
<li>i</li>
|
41
63
|
|
42
|
-
|
64
|
+
<li>j</li>
|
43
65
|
|
44
|
-
h
|
45
66
|
|
46
|
-
i
|
47
67
|
|
48
|
-
|
68
|
+
</ul>
|
69
|
+
<div class='res'>178</div>
|
70
|
+
<p>
|
71
|
+
<p>I like preserved text:</p>
|
72
|
+
|
73
|
+
|
74
|
+
<pre><code>Foo
 Bar!
Baz</code></pre>
|
75
|
+
</p>
|
49
76
|
<ul>
|
50
77
|
<li>Foo</li>
|
51
78
|
<li>Bar</li>
|
@@ -54,4 +81,6 @@ This
|
|
54
81
|
Text!
|
55
82
|
Hello, World!
|
56
83
|
How are you doing today?
|
57
|
-
|
84
|
+
<div class="foo">
|
85
|
+
<p>I think &mdash; or do I?</p>
|
86
|
+
</div>
|
@@ -24,9 +24,7 @@
|
|
24
24
|
</p>
|
25
25
|
</div>
|
26
26
|
<p>foo</p>
|
27
|
-
<p>
|
28
|
-
reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeally loooooooooooooooooong
|
29
|
-
</p>
|
27
|
+
<p>reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeally loooooooooooooooooong</p>
|
30
28
|
<div class='woah'>
|
31
29
|
<div id='funky'>
|
32
30
|
<div>
|
@@ -56,6 +54,7 @@ foo
|
|
56
54
|
@foo =
|
57
55
|
value one
|
58
56
|
</p>
|
57
|
+
Toplevel? false
|
59
58
|
<p>
|
60
59
|
@foo =
|
61
60
|
value three
|
@@ -27,9 +27,6 @@ stuff followed by whitespace
|
|
27
27
|
yee\ha
|
28
28
|
</p>
|
29
29
|
<!-- Short comment -->
|
30
|
-
<!--
|
31
|
-
This is a really long comment look how long it is it should be on a line of its own don't you think?
|
32
|
-
-->
|
33
30
|
<!--
|
34
31
|
This is a block comment
|
35
32
|
cool, huh?
|
@@ -62,6 +59,5 @@ testtest
|
|
62
59
|
<p class='article foo' id='article_1'>Blah</p>
|
63
60
|
<p class='article quux qux' id='article_1'>Blump</p>
|
64
61
|
Woah inner quotes
|
65
|
-
<p class='dynamic_quote' dyn='3' quotes="single '">
|
66
|
-
|
67
|
-
<p class='dynamic_atomic' dyn='3' />
|
62
|
+
<p class='dynamic_quote' dyn='3' quotes="single '"></p>
|
63
|
+
<p class='dynamic_self_closing' dyn='3' />
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<p>
|
2
|
+
<q>Foo</q>
|
3
|
+
</p>
|
4
|
+
<p>
|
5
|
+
<q a='2'>Foo</q>
|
6
|
+
</p>
|
7
|
+
<p>
|
8
|
+
<q>Foo
|
9
|
+
Bar</q>
|
10
|
+
</p>
|
11
|
+
<p>
|
12
|
+
<q a='2'>Foo
|
13
|
+
Bar</q>
|
14
|
+
</p>
|
15
|
+
<p>
|
16
|
+
<q>Foo
|
17
|
+
Bar</q>
|
18
|
+
</p>
|
19
|
+
<p>
|
20
|
+
<q a='2'>Foo
|
21
|
+
Bar</q>
|
22
|
+
</p>
|
23
|
+
<p>
|
24
|
+
<q><div>
|
25
|
+
Foo
|
26
|
+
Bar
|
27
|
+
</div></q>
|
28
|
+
</p>
|
29
|
+
<p>
|
30
|
+
<q a='2'><div>
|
31
|
+
Foo
|
32
|
+
Bar
|
33
|
+
</div></q>
|
34
|
+
</p>
|
@@ -0,0 +1,148 @@
|
|
1
|
+
<p>
|
2
|
+
<p><q>
|
3
|
+
Foo
|
4
|
+
</q></p>
|
5
|
+
</p>
|
6
|
+
<p>
|
7
|
+
<p><q a='2'>
|
8
|
+
Foo
|
9
|
+
</q></p>
|
10
|
+
</p>
|
11
|
+
<p>
|
12
|
+
<p><q>Foo</q></p>
|
13
|
+
</p>
|
14
|
+
<p>
|
15
|
+
<p><q a='2'>Foo</q></p>
|
16
|
+
</p>
|
17
|
+
<p>
|
18
|
+
<p><q>
|
19
|
+
Foo
|
20
|
+
</q></p>
|
21
|
+
</p>
|
22
|
+
<p>
|
23
|
+
<p><q a='2'>
|
24
|
+
Foo
|
25
|
+
</q></p>
|
26
|
+
</p>
|
27
|
+
<p>
|
28
|
+
<p><q>Foo</q></p>
|
29
|
+
</p>
|
30
|
+
<p>
|
31
|
+
<p><q a='2'>Foo</q></p>
|
32
|
+
</p>
|
33
|
+
<p>
|
34
|
+
<p><q>
|
35
|
+
Foo
|
36
|
+
Bar
|
37
|
+
</q></p>
|
38
|
+
</p>
|
39
|
+
<p>
|
40
|
+
<p><q a='2'>
|
41
|
+
Foo
|
42
|
+
Bar
|
43
|
+
</q></p>
|
44
|
+
</p>
|
45
|
+
<p>
|
46
|
+
<p><q>
|
47
|
+
Foo
|
48
|
+
Bar
|
49
|
+
</q></p>
|
50
|
+
</p>
|
51
|
+
<p>
|
52
|
+
<p><q a='2'>
|
53
|
+
Foo
|
54
|
+
Bar
|
55
|
+
</q></p>
|
56
|
+
</p>
|
57
|
+
<p>
|
58
|
+
<p>
|
59
|
+
foo<q>
|
60
|
+
Foo
|
61
|
+
</q>bar
|
62
|
+
</p>
|
63
|
+
</p>
|
64
|
+
<p>
|
65
|
+
<p>
|
66
|
+
foo<q a='2'>
|
67
|
+
Foo
|
68
|
+
</q>bar
|
69
|
+
</p>
|
70
|
+
</p>
|
71
|
+
<p>
|
72
|
+
<p>
|
73
|
+
foo<q>Foo</q>bar
|
74
|
+
</p>
|
75
|
+
</p>
|
76
|
+
<p>
|
77
|
+
<p>
|
78
|
+
foo<q a='2'>Foo</q>bar
|
79
|
+
</p>
|
80
|
+
</p>
|
81
|
+
<p>
|
82
|
+
<p>
|
83
|
+
foo<q>
|
84
|
+
Foo
|
85
|
+
</q>bar
|
86
|
+
</p>
|
87
|
+
</p>
|
88
|
+
<p>
|
89
|
+
<p>
|
90
|
+
foo<q a='2'>
|
91
|
+
Foo
|
92
|
+
</q>bar
|
93
|
+
</p>
|
94
|
+
</p>
|
95
|
+
<p>
|
96
|
+
<p>
|
97
|
+
foo<q>Foo</q>bar
|
98
|
+
</p>
|
99
|
+
</p>
|
100
|
+
<p>
|
101
|
+
<p>
|
102
|
+
foo<q a='2'>Foo</q>bar
|
103
|
+
</p>
|
104
|
+
</p>
|
105
|
+
<p>
|
106
|
+
<p>
|
107
|
+
foo<q>
|
108
|
+
Foo
|
109
|
+
Bar
|
110
|
+
</q>bar
|
111
|
+
</p>
|
112
|
+
</p>
|
113
|
+
<p>
|
114
|
+
<p>
|
115
|
+
foo<q a='2'>
|
116
|
+
Foo
|
117
|
+
Bar
|
118
|
+
</q>bar
|
119
|
+
</p>
|
120
|
+
</p>
|
121
|
+
<p>
|
122
|
+
<p>
|
123
|
+
foo<q>
|
124
|
+
Foo
|
125
|
+
Bar
|
126
|
+
</q>bar
|
127
|
+
</p>
|
128
|
+
</p>
|
129
|
+
<p>
|
130
|
+
<p>
|
131
|
+
foo<q a='2'>
|
132
|
+
Foo
|
133
|
+
Bar
|
134
|
+
</q>bar
|
135
|
+
</p>
|
136
|
+
</p>
|
137
|
+
<p>
|
138
|
+
<p><q></q></p>
|
139
|
+
</p>
|
140
|
+
<p>
|
141
|
+
<p><q /></p>
|
142
|
+
</p>
|
143
|
+
<p>
|
144
|
+
<p><q a='2'></q></p>
|
145
|
+
</p>
|
146
|
+
<p>
|
147
|
+
<p><q a='2' /></p>
|
148
|
+
</p>
|