merbjedi-haml 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/FAQ +138 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +332 -0
- data/REVISION +1 -0
- data/Rakefile +184 -0
- data/VERSION +1 -0
- data/bin/css2sass +7 -0
- data/bin/haml +9 -0
- data/bin/html2haml +7 -0
- data/bin/sass +8 -0
- data/extra/haml-mode.el +434 -0
- data/extra/sass-mode.el +98 -0
- data/init.rb +8 -0
- data/lib/haml.rb +1025 -0
- data/lib/haml/buffer.rb +255 -0
- data/lib/haml/engine.rb +268 -0
- data/lib/haml/error.rb +22 -0
- data/lib/haml/exec.rb +395 -0
- data/lib/haml/filters.rb +276 -0
- data/lib/haml/helpers.rb +465 -0
- data/lib/haml/helpers/action_view_extensions.rb +45 -0
- data/lib/haml/helpers/action_view_mods.rb +181 -0
- data/lib/haml/html.rb +218 -0
- data/lib/haml/precompiler.rb +896 -0
- data/lib/haml/shared.rb +45 -0
- data/lib/haml/template.rb +51 -0
- data/lib/haml/template/patch.rb +58 -0
- data/lib/haml/template/plugin.rb +72 -0
- data/lib/haml/util.rb +77 -0
- data/lib/haml/version.rb +47 -0
- data/lib/sass.rb +1062 -0
- data/lib/sass/css.rb +388 -0
- data/lib/sass/engine.rb +501 -0
- data/lib/sass/environment.rb +33 -0
- data/lib/sass/error.rb +35 -0
- data/lib/sass/plugin.rb +203 -0
- data/lib/sass/plugin/merb.rb +56 -0
- data/lib/sass/plugin/rails.rb +24 -0
- data/lib/sass/repl.rb +44 -0
- data/lib/sass/script.rb +38 -0
- data/lib/sass/script/bool.rb +13 -0
- data/lib/sass/script/color.rb +97 -0
- data/lib/sass/script/funcall.rb +28 -0
- data/lib/sass/script/functions.rb +122 -0
- data/lib/sass/script/lexer.rb +144 -0
- data/lib/sass/script/literal.rb +60 -0
- data/lib/sass/script/number.rb +231 -0
- data/lib/sass/script/operation.rb +30 -0
- data/lib/sass/script/parser.rb +142 -0
- data/lib/sass/script/string.rb +42 -0
- data/lib/sass/script/unary_operation.rb +21 -0
- data/lib/sass/script/variable.rb +20 -0
- data/lib/sass/tree/attr_node.rb +64 -0
- data/lib/sass/tree/comment_node.rb +30 -0
- data/lib/sass/tree/debug_node.rb +22 -0
- data/lib/sass/tree/directive_node.rb +50 -0
- data/lib/sass/tree/file_node.rb +27 -0
- data/lib/sass/tree/for_node.rb +29 -0
- data/lib/sass/tree/if_node.rb +27 -0
- data/lib/sass/tree/mixin_def_node.rb +18 -0
- data/lib/sass/tree/mixin_node.rb +34 -0
- data/lib/sass/tree/node.rb +97 -0
- data/lib/sass/tree/rule_node.rb +120 -0
- data/lib/sass/tree/variable_node.rb +24 -0
- data/lib/sass/tree/while_node.rb +20 -0
- data/rails/init.rb +1 -0
- data/test/benchmark.rb +99 -0
- data/test/haml/engine_test.rb +852 -0
- data/test/haml/helper_test.rb +224 -0
- data/test/haml/html2haml_test.rb +92 -0
- data/test/haml/markaby/standard.mab +52 -0
- data/test/haml/mocks/article.rb +6 -0
- data/test/haml/results/content_for_layout.xhtml +15 -0
- data/test/haml/results/eval_suppressed.xhtml +9 -0
- data/test/haml/results/filters.xhtml +62 -0
- data/test/haml/results/helpers.xhtml +93 -0
- data/test/haml/results/helpful.xhtml +10 -0
- data/test/haml/results/just_stuff.xhtml +68 -0
- data/test/haml/results/list.xhtml +12 -0
- data/test/haml/results/nuke_inner_whitespace.xhtml +40 -0
- data/test/haml/results/nuke_outer_whitespace.xhtml +148 -0
- data/test/haml/results/original_engine.xhtml +20 -0
- data/test/haml/results/partial_layout.xhtml +5 -0
- data/test/haml/results/partials.xhtml +21 -0
- data/test/haml/results/render_layout.xhtml +3 -0
- data/test/haml/results/silent_script.xhtml +74 -0
- data/test/haml/results/standard.xhtml +42 -0
- data/test/haml/results/tag_parsing.xhtml +23 -0
- data/test/haml/results/very_basic.xhtml +5 -0
- data/test/haml/results/whitespace_handling.xhtml +89 -0
- data/test/haml/rhtml/_av_partial_1.rhtml +12 -0
- data/test/haml/rhtml/_av_partial_2.rhtml +8 -0
- data/test/haml/rhtml/action_view.rhtml +62 -0
- data/test/haml/rhtml/standard.rhtml +54 -0
- data/test/haml/template_test.rb +204 -0
- data/test/haml/templates/_av_partial_1.haml +9 -0
- data/test/haml/templates/_av_partial_1_ugly.haml +9 -0
- data/test/haml/templates/_av_partial_2.haml +5 -0
- data/test/haml/templates/_av_partial_2_ugly.haml +5 -0
- data/test/haml/templates/_layout.erb +3 -0
- data/test/haml/templates/_layout_for_partial.haml +3 -0
- data/test/haml/templates/_partial.haml +8 -0
- data/test/haml/templates/_text_area.haml +3 -0
- data/test/haml/templates/action_view.haml +47 -0
- data/test/haml/templates/action_view_ugly.haml +47 -0
- data/test/haml/templates/breakage.haml +8 -0
- data/test/haml/templates/content_for_layout.haml +10 -0
- data/test/haml/templates/eval_suppressed.haml +11 -0
- data/test/haml/templates/filters.haml +66 -0
- data/test/haml/templates/helpers.haml +95 -0
- data/test/haml/templates/helpful.haml +11 -0
- data/test/haml/templates/just_stuff.haml +83 -0
- data/test/haml/templates/list.haml +12 -0
- data/test/haml/templates/nuke_inner_whitespace.haml +32 -0
- data/test/haml/templates/nuke_outer_whitespace.haml +144 -0
- data/test/haml/templates/original_engine.haml +17 -0
- data/test/haml/templates/partial_layout.haml +3 -0
- data/test/haml/templates/partialize.haml +1 -0
- data/test/haml/templates/partials.haml +12 -0
- data/test/haml/templates/render_layout.haml +2 -0
- data/test/haml/templates/silent_script.haml +40 -0
- data/test/haml/templates/standard.haml +42 -0
- data/test/haml/templates/standard_ugly.haml +42 -0
- data/test/haml/templates/tag_parsing.haml +21 -0
- data/test/haml/templates/very_basic.haml +4 -0
- data/test/haml/templates/whitespace_handling.haml +87 -0
- data/test/linked_rails.rb +12 -0
- data/test/sass/css2sass_test.rb +193 -0
- data/test/sass/engine_test.rb +752 -0
- data/test/sass/functions_test.rb +96 -0
- data/test/sass/more_results/more1.css +9 -0
- data/test/sass/more_results/more1_with_line_comments.css +26 -0
- data/test/sass/more_results/more_import.css +29 -0
- data/test/sass/more_templates/_more_partial.sass +2 -0
- data/test/sass/more_templates/more1.sass +23 -0
- data/test/sass/more_templates/more_import.sass +11 -0
- data/test/sass/plugin_test.rb +208 -0
- data/test/sass/results/alt.css +4 -0
- data/test/sass/results/basic.css +9 -0
- data/test/sass/results/compact.css +5 -0
- data/test/sass/results/complex.css +87 -0
- data/test/sass/results/compressed.css +1 -0
- data/test/sass/results/expanded.css +19 -0
- data/test/sass/results/import.css +29 -0
- data/test/sass/results/line_numbers.css +49 -0
- data/test/sass/results/mixins.css +95 -0
- data/test/sass/results/multiline.css +24 -0
- data/test/sass/results/nested.css +22 -0
- data/test/sass/results/parent_ref.css +13 -0
- data/test/sass/results/script.css +16 -0
- data/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
- data/test/sass/results/subdir/subdir.css +3 -0
- data/test/sass/results/units.css +11 -0
- data/test/sass/script_test.rb +152 -0
- data/test/sass/templates/_partial.sass +2 -0
- data/test/sass/templates/alt.sass +16 -0
- data/test/sass/templates/basic.sass +23 -0
- data/test/sass/templates/bork.sass +2 -0
- data/test/sass/templates/bork2.sass +2 -0
- data/test/sass/templates/compact.sass +17 -0
- data/test/sass/templates/complex.sass +309 -0
- data/test/sass/templates/compressed.sass +15 -0
- data/test/sass/templates/expanded.sass +17 -0
- data/test/sass/templates/import.sass +11 -0
- data/test/sass/templates/importee.sass +19 -0
- data/test/sass/templates/line_numbers.sass +13 -0
- data/test/sass/templates/mixins.sass +76 -0
- data/test/sass/templates/multiline.sass +20 -0
- data/test/sass/templates/nested.sass +25 -0
- data/test/sass/templates/parent_ref.sass +25 -0
- data/test/sass/templates/script.sass +101 -0
- data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
- data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
- data/test/sass/templates/subdir/subdir.sass +6 -0
- data/test/sass/templates/units.sass +11 -0
- data/test/test_helper.rb +21 -0
- metadata +273 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'>
|
3
|
+
<head>
|
4
|
+
<title>Hampton Catlin Is Totally Awesome</title>
|
5
|
+
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<!-- You're In my house now! -->
|
9
|
+
<div class='header'>
|
10
|
+
Yes, ladies and gentileman. He is just that egotistical.
|
11
|
+
Fantastic! This should be multi-line output
|
12
|
+
The question is if this would translate! Ahah!
|
13
|
+
20
|
14
|
+
</div>
|
15
|
+
<div id='body'> Quotes should be loved! Just like people!</div>
|
16
|
+
Wow.|
|
17
|
+
<p>
|
18
|
+
Holy cow multiline tags! A pipe (|) even!
|
19
|
+
PipesIgnored|PipesIgnored|PipesIgnored|
|
20
|
+
1|2|3
|
21
|
+
</p>
|
22
|
+
<div class='silent'>
|
23
|
+
this shouldn't evaluate but now it should!
|
24
|
+
</div>
|
25
|
+
<ul class='really cool'>
|
26
|
+
<li>a</li>
|
27
|
+
<li>b</li>
|
28
|
+
<li>c</li>
|
29
|
+
<li>d</li>
|
30
|
+
<li>e</li>
|
31
|
+
<li>f</li>
|
32
|
+
</ul>
|
33
|
+
<div class='of_divs_with_underscore' id='combo'>with this text</div>
|
34
|
+
foo
|
35
|
+
<div class='footer'>
|
36
|
+
<strong class='shout'>
|
37
|
+
This is a really long ruby quote. It should be loved and wrapped because its more than 50 characters. This value may change in the future and this test may look stupid.
|
38
|
+
So, I'm just making it *really* long. God, I hope this works
|
39
|
+
</strong>
|
40
|
+
</div>
|
41
|
+
</body>
|
42
|
+
</html>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<div class='tags'>
|
2
|
+
<foo>1</foo>
|
3
|
+
<FOO>2</FOO>
|
4
|
+
<fooBAR>3</fooBAR>
|
5
|
+
<fooBar>4</fooBar>
|
6
|
+
<foo_bar>5</foo_bar>
|
7
|
+
<foo-bar>6</foo-bar>
|
8
|
+
<foo:bar>7</foo:bar>
|
9
|
+
<foo class='bar'>8</foo>
|
10
|
+
<fooBAr_baz:boom_bar>9</fooBAr_baz:boom_bar>
|
11
|
+
<foo13>10</foo13>
|
12
|
+
<foo2u>11</foo2u>
|
13
|
+
</div>
|
14
|
+
<div class='classes'>
|
15
|
+
<p class='foo bar' id='boom'></p>
|
16
|
+
<div class='fooBar'>a</div>
|
17
|
+
<div class='foo-bar'>b</div>
|
18
|
+
<div class='foo_bar'>c</div>
|
19
|
+
<div class='FOOBAR'>d</div>
|
20
|
+
<div class='foo16'>e</div>
|
21
|
+
<div class='123'>f</div>
|
22
|
+
<div class='foo2u'>g</div>
|
23
|
+
</div>
|
@@ -0,0 +1,89 @@
|
|
1
|
+
<div id='whitespace_test'>
|
2
|
+
<div class='text_area_test_area'>
|
3
|
+
<textarea>Oneline</textarea>
|
4
|
+
</div>
|
5
|
+
<textarea>BLAH
|
6
|
+
</textarea>
|
7
|
+
<div class='text_area_test_area'>
|
8
|
+
<textarea>Two
lines</textarea>
|
9
|
+
</div>
|
10
|
+
<textarea>BLAH
|
11
|
+
</textarea>
|
12
|
+
<div class='text_area_test_area'>
|
13
|
+
<textarea>Oneline</textarea>
|
14
|
+
</div>
|
15
|
+
<textarea>BLAH</textarea>
|
16
|
+
<div class='text_area_test_area'>
|
17
|
+
<textarea>Two
lines</textarea>
|
18
|
+
</div>
|
19
|
+
<textarea>BLAH</textarea>
|
20
|
+
<div id='flattened'>
|
21
|
+
<div class='text_area_test_area'>
|
22
|
+
<textarea>Two
lines</textarea>
|
23
|
+
</div>
|
24
|
+
<textarea>BLAH</textarea>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
<div class='hithere'>
|
28
|
+
Foo bar
|
29
|
+
<pre>foo bar</pre>
|
30
|
+
<pre>foo
bar</pre>
|
31
|
+
<p><pre>foo
bar</pre></p>
|
32
|
+
<p>
|
33
|
+
foo
|
34
|
+
bar
|
35
|
+
</p>
|
36
|
+
</div>
|
37
|
+
<div class='foo'>
|
38
|
+
13
|
39
|
+
<textarea>
|
40
|
+
a
|
41
|
+
</textarea>
|
42
|
+
<textarea>
a</textarea>
|
43
|
+
</div>
|
44
|
+
<div id='whitespace_test'>
|
45
|
+
<div class='text_area_test_area'>
|
46
|
+
<textarea>Oneline</textarea>
|
47
|
+
</div>
|
48
|
+
<textarea>BLAH
|
49
|
+
</textarea>
|
50
|
+
<div class='text_area_test_area'>
|
51
|
+
<textarea>Two
lines</textarea>
|
52
|
+
</div>
|
53
|
+
<textarea>BLAH
|
54
|
+
</textarea>
|
55
|
+
<div class='text_area_test_area'>
|
56
|
+
<textarea>Oneline</textarea>
|
57
|
+
</div>
|
58
|
+
<textarea>BLAH</textarea>
|
59
|
+
<div class='text_area_test_area'>
|
60
|
+
<textarea>Two
lines</textarea>
|
61
|
+
</div>
|
62
|
+
<textarea>BLAH</textarea>
|
63
|
+
<div id='flattened'>
|
64
|
+
<div class='text_area_test_area'>
|
65
|
+
<textarea>Two
lines</textarea>
|
66
|
+
</div>
|
67
|
+
<textarea>BLAH</textarea>
|
68
|
+
</div>
|
69
|
+
</div>
|
70
|
+
<div class='hithere'>
|
71
|
+
Foo bar
|
72
|
+
<pre>foo bar</pre>
|
73
|
+
<pre>foo
bar</pre>
|
74
|
+
<p><pre>foo
bar</pre></p>
|
75
|
+
<p>
|
76
|
+
foo
|
77
|
+
bar
|
78
|
+
</p>
|
79
|
+
<pre> ___
 ,o88888
 ,o8888888'
 ,:o:o:oooo. ,8O88Pd8888"
 ,.::.::o:ooooOoOoO. ,oO8O8Pd888'"
 ,.:.::o:ooOoOoOO8O8OOo.8OOPd8O8O"
 , ..:.::o:ooOoOOOO8OOOOo.FdO8O8"
 , ..:.::o:ooOoOO8O888O8O,COCOO"
 , . ..:.::o:ooOoOOOO8OOOOCOCO"
 . ..:.::o:ooOoOoOO8O8OCCCC"o
 . ..:.::o:ooooOoCoCCC"o:o
 . ..:.::o:o:,cooooCo"oo:o:
 ` . . ..:.:cocoooo"'o:o:::'
 .` . ..::ccccoc"'o:o:o:::'
 :.:. ,c:cccc"':.:.:.:.:.'
 ..:.:"'`::::c:"'..:.:.:.:.:.' http://www.chris.com/ASCII/
 ...:.'.:.::::"' . . . . .'
 .. . ....:."' ` . . . ''
 . . . ...."'
 .. . ."' -hrr-
 .


 It's a planet!
%strong This shouldn't be bold!</pre>
|
80
|
+
<strong>This should!</strong>
|
81
|
+
<textarea> ___ ___ ___ ___ 
 /\__\ /\ \ /\__\ /\__\
 /:/ / /::\ \ /::| | /:/ /
 /:/__/ /:/\:\ \ /:|:| | /:/ / 
 /::\ \ ___ /::\~\:\ \ /:/|:|__|__ /:/ / 
 /:/\:\ /\__\ /:/\:\ \:\__\ /:/ |::::\__\ /:/__/ 
 \/__\:\/:/ / \/__\:\/:/ / \/__/~~/:/ / \:\ \ 
 \::/ / \::/ / /:/ / \:\ \ 
 /:/ / /:/ / /:/ / \:\ \ 
 /:/ / /:/ / /:/ / \:\__\
 \/__/ \/__/ \/__/ \/__/
 
 Many
 thanks
 to
 http://www.network-science.de/ascii/
|
82
|
+
<strong>indeed!</strong></textarea>
|
83
|
+
</div>
|
84
|
+
<div class='foo'>
|
85
|
+
13
|
86
|
+
</div>
|
87
|
+
<pre> __ ______ __ ______
.----.| |--.|__ |.----.| |--..--------.| __ |
| __|| ||__ || __|| < | || __ |
|____||__|__||______||____||__|__||__|__|__||______|</pre>
|
88
|
+
<pre>foo
|
89
|
+
bar</pre>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<h2>This is a pretty complicated partial</h2>
|
2
|
+
<div class="partial">
|
3
|
+
<p>It has several nested partials,</p>
|
4
|
+
<ul>
|
5
|
+
<% 5.times do %>
|
6
|
+
<li>
|
7
|
+
<strong>Partial:</strong>
|
8
|
+
<% @nesting = 5 %>
|
9
|
+
<%= render :partial => 'haml/rhtml/av_partial_2' %>
|
10
|
+
<% end %>
|
11
|
+
</ul>
|
12
|
+
</div>
|
@@ -0,0 +1,62 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en-US'>
|
3
|
+
<head>
|
4
|
+
<title>Hampton Catlin Is Totally Awesome</title>
|
5
|
+
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<h1>
|
9
|
+
This is very much like the standard template,
|
10
|
+
except that it has some ActionView-specific stuff.
|
11
|
+
It's only used for benchmarking.
|
12
|
+
</h1>
|
13
|
+
<div class="crazy_partials">
|
14
|
+
<%= render :partial => 'haml/rhtml/av_partial_1' %>
|
15
|
+
</div>
|
16
|
+
<!-- You're In my house now! -->
|
17
|
+
<div class='header'>
|
18
|
+
Yes, ladies and gentileman. He is just that egotistical.
|
19
|
+
Fantastic! This should be multi-line output
|
20
|
+
The question is if this would translate! Ahah!
|
21
|
+
<%= 1 + 9 + 8 + 2 %>
|
22
|
+
<%# numbers should work and this should be ignored %>
|
23
|
+
</div>
|
24
|
+
<% 120.times do |number| -%>
|
25
|
+
<%= number %>
|
26
|
+
<% end -%>
|
27
|
+
<div id='body'><%= " Quotes should be loved! Just like people!" %></div>
|
28
|
+
Wow.
|
29
|
+
<p>
|
30
|
+
<%= "Holy cow " +
|
31
|
+
"multiline " +
|
32
|
+
"tags! " +
|
33
|
+
"A pipe (|) even!" %>
|
34
|
+
<%= [1, 2, 3].collect { |n| "PipesIgnored|" } %>
|
35
|
+
<%= [1, 2, 3].collect { |n|
|
36
|
+
n.to_s
|
37
|
+
}.join("|") %>
|
38
|
+
</p>
|
39
|
+
<div class='silent'>
|
40
|
+
<% foo = String.new
|
41
|
+
foo << "this"
|
42
|
+
foo << " shouldn't"
|
43
|
+
foo << " evaluate" %>
|
44
|
+
<%= foo + "but now it should!" %>
|
45
|
+
<%# Woah crap a comment! %>
|
46
|
+
</div>
|
47
|
+
<ul class='really cool'>
|
48
|
+
<% ('a'..'f').each do |a|%>
|
49
|
+
<li><%= a %>
|
50
|
+
<% end %>
|
51
|
+
<div class='of_divs_with_underscore' id='combo'><%= @should_eval = "with this text" %></div>
|
52
|
+
<%= [ 104, 101, 108, 108, 111 ].map do |byte|
|
53
|
+
byte.chr
|
54
|
+
end %>
|
55
|
+
<div class='footer'>
|
56
|
+
<strong class='shout'>
|
57
|
+
<%= "This is a really long ruby quote. It should be loved and wrapped because its more than 50 characters. This value may change in the future and this test may look stupid.\n" +
|
58
|
+
" So, I'm just making it *really* long. God, I hope this works" %>
|
59
|
+
</strong>
|
60
|
+
</div>
|
61
|
+
</body>
|
62
|
+
</html>
|
@@ -0,0 +1,54 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en-US'>
|
3
|
+
<head>
|
4
|
+
<title>Hampton Catlin Is Totally Awesome</title>
|
5
|
+
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<!-- You're In my house now! -->
|
9
|
+
<div class='header'>
|
10
|
+
Yes, ladies and gentileman. He is just that egotistical.
|
11
|
+
Fantastic! This should be multi-line output
|
12
|
+
The question is if this would translate! Ahah!
|
13
|
+
<%= 1 + 9 + 8 + 2 %>
|
14
|
+
<%# numbers should work and this should be ignored %>
|
15
|
+
</div>
|
16
|
+
<% 120.times do |number| -%>
|
17
|
+
<%= number %>
|
18
|
+
<% end -%>
|
19
|
+
<div id='body'><%= " Quotes should be loved! Just like people!" %></div>
|
20
|
+
Wow.
|
21
|
+
<p>
|
22
|
+
<%= "Holy cow " +
|
23
|
+
"multiline " +
|
24
|
+
"tags! " +
|
25
|
+
"A pipe (|) even!" %>
|
26
|
+
<%= [1, 2, 3].collect { |n| "PipesIgnored|" }.join %>
|
27
|
+
<%= [1, 2, 3].collect { |n|
|
28
|
+
n.to_s
|
29
|
+
}.join("|") %>
|
30
|
+
</p>
|
31
|
+
<div class='silent'>
|
32
|
+
<% foo = String.new
|
33
|
+
foo << "this"
|
34
|
+
foo << " shouldn't"
|
35
|
+
foo << " evaluate" %>
|
36
|
+
<%= foo + "but now it should!" %>
|
37
|
+
<%# Woah crap a comment! %>
|
38
|
+
</div>
|
39
|
+
<ul class='really cool'>
|
40
|
+
<% ('a'..'f').each do |a|%>
|
41
|
+
<li><%= a %>
|
42
|
+
<% end %>
|
43
|
+
<div class='of_divs_with_underscore' id='combo'><%= @should_eval = "with this text" %></div>
|
44
|
+
<%= "foo".each_line do |line|
|
45
|
+
nil
|
46
|
+
end %>
|
47
|
+
<div class='footer'>
|
48
|
+
<strong class='shout'>
|
49
|
+
<%= "This is a really long ruby quote. It should be loved and wrapped because its more than 50 characters. This value may change in the future and this test may look stupid.\n" +
|
50
|
+
" So, I'm just making it *really* long. God, I hope this works" %>
|
51
|
+
</strong>
|
52
|
+
</div>
|
53
|
+
</body>
|
54
|
+
</html>
|
@@ -0,0 +1,204 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
3
|
+
require 'haml/template'
|
4
|
+
require 'sass/plugin'
|
5
|
+
require File.dirname(__FILE__) + '/mocks/article'
|
6
|
+
|
7
|
+
require 'action_pack/version'
|
8
|
+
|
9
|
+
module Haml::Filters::Test
|
10
|
+
include Haml::Filters::Base
|
11
|
+
|
12
|
+
def render(text)
|
13
|
+
"TESTING HAHAHAHA!"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module Haml::Helpers
|
18
|
+
def test_partial(name, locals = {})
|
19
|
+
Haml::Engine.new(File.read(File.join(TemplateTest::TEMPLATE_PATH, "_#{name}.haml"))).render(self, locals)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Egocentic
|
24
|
+
def method_missing(*args)
|
25
|
+
self
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class DummyController
|
30
|
+
attr_accessor :logger
|
31
|
+
def initialize
|
32
|
+
@logger = Egocentic.new
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.controller_path
|
36
|
+
''
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class TemplateTest < Test::Unit::TestCase
|
41
|
+
TEMPLATE_PATH = File.join(File.dirname(__FILE__), "templates")
|
42
|
+
TEMPLATES = %w{ very_basic standard helpers
|
43
|
+
whitespace_handling original_engine list helpful
|
44
|
+
silent_script tag_parsing just_stuff partials
|
45
|
+
filters nuke_outer_whitespace nuke_inner_whitespace
|
46
|
+
render_layout }
|
47
|
+
# partial layouts were introduced in 2.0.0
|
48
|
+
TEMPLATES << 'partial_layout' unless ActionPack::VERSION::MAJOR < 2
|
49
|
+
|
50
|
+
def setup
|
51
|
+
@base = create_base
|
52
|
+
|
53
|
+
# filters template uses :sass
|
54
|
+
Sass::Plugin.options.update(:line_comments => true, :style => :compact)
|
55
|
+
end
|
56
|
+
|
57
|
+
def create_base
|
58
|
+
vars = { 'article' => Article.new, 'foo' => 'value one' }
|
59
|
+
|
60
|
+
unless Haml::Util.has?(:instance_method, ActionView::Base, :finder)
|
61
|
+
base = ActionView::Base.new(TEMPLATE_PATH, vars)
|
62
|
+
else
|
63
|
+
# Rails 2.1.0
|
64
|
+
base = ActionView::Base.new([], vars)
|
65
|
+
base.finder.append_view_path(TEMPLATE_PATH)
|
66
|
+
end
|
67
|
+
|
68
|
+
if Haml::Util.has?(:private_method, base, :evaluate_assigns)
|
69
|
+
base.send(:evaluate_assigns)
|
70
|
+
else
|
71
|
+
# Rails 2.2
|
72
|
+
base.send(:_evaluate_assigns_and_ivars)
|
73
|
+
end
|
74
|
+
|
75
|
+
# This is used by form_for.
|
76
|
+
# It's usually provided by ActionController::Base.
|
77
|
+
def base.protect_against_forgery?; false; end
|
78
|
+
|
79
|
+
base.controller = DummyController.new
|
80
|
+
base
|
81
|
+
end
|
82
|
+
|
83
|
+
def render(text)
|
84
|
+
Haml::Engine.new(text).to_html(@base)
|
85
|
+
end
|
86
|
+
|
87
|
+
def load_result(name)
|
88
|
+
@result = ''
|
89
|
+
File.new(File.dirname(__FILE__) + "/results/#{name}.xhtml").each_line { |l| @result += l }
|
90
|
+
@result
|
91
|
+
end
|
92
|
+
|
93
|
+
def assert_renders_correctly(name, &render_method)
|
94
|
+
if ActionPack::VERSION::MAJOR < 2 || ActionPack::VERSION::MINOR < 2
|
95
|
+
render_method ||= proc { |name| @base.render(name) }
|
96
|
+
else
|
97
|
+
render_method ||= proc { |name| @base.render(:file => name) }
|
98
|
+
end
|
99
|
+
|
100
|
+
load_result(name).split("\n").zip(render_method[name].split("\n")).each_with_index do |pair, line|
|
101
|
+
message = "template: #{name}\nline: #{line}"
|
102
|
+
assert_equal(pair.first, pair.last, message)
|
103
|
+
end
|
104
|
+
rescue ActionView::TemplateError => e
|
105
|
+
if e.message =~ /Can't run [\w:]+ filter; required (one of|file) ((?:'\w+'(?: or )?)+)(, but none were found| not found)/
|
106
|
+
puts "\nCouldn't require #{$2}; skipping a test."
|
107
|
+
else
|
108
|
+
raise e
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_empty_render_should_remain_empty
|
113
|
+
assert_equal('', render(''))
|
114
|
+
end
|
115
|
+
|
116
|
+
TEMPLATES.each do |template|
|
117
|
+
define_method "test_template_should_render_correctly [template: #{template}] " do
|
118
|
+
assert_renders_correctly template
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_templates_should_render_correctly_with_render_proc
|
123
|
+
assert_renders_correctly("standard") do |name|
|
124
|
+
engine = Haml::Engine.new(File.read(File.dirname(__FILE__) + "/templates/#{name}.haml"))
|
125
|
+
engine.render_proc(@base).call
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_templates_should_render_correctly_with_def_method
|
130
|
+
assert_renders_correctly("standard") do |name|
|
131
|
+
engine = Haml::Engine.new(File.read(File.dirname(__FILE__) + "/templates/#{name}.haml"))
|
132
|
+
engine.def_method(@base, "render_standard")
|
133
|
+
@base.render_standard
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_action_view_templates_render_correctly
|
138
|
+
@base.instance_variable_set("@content_for_layout", 'Lorem ipsum dolor sit amet')
|
139
|
+
assert_renders_correctly 'content_for_layout'
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_instance_variables_should_work_inside_templates
|
143
|
+
@base.instance_variable_set("@content_for_layout", 'something')
|
144
|
+
assert_equal("<p>something</p>", render("%p= @content_for_layout").chomp)
|
145
|
+
|
146
|
+
@base.instance_eval("@author = 'Hampton Catlin'")
|
147
|
+
assert_equal("<div class='author'>Hampton Catlin</div>", render(".author= @author").chomp)
|
148
|
+
|
149
|
+
@base.instance_eval("@author = 'Hampton'")
|
150
|
+
assert_equal("Hampton", render("= @author").chomp)
|
151
|
+
|
152
|
+
@base.instance_eval("@author = 'Catlin'")
|
153
|
+
assert_equal("Catlin", render("= @author").chomp)
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_instance_variables_should_work_inside_attributes
|
157
|
+
@base.instance_eval("@author = 'hcatlin'")
|
158
|
+
assert_equal("<p class='hcatlin'>foo</p>", render("%p{:class => @author} foo").chomp)
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_template_renders_should_eval
|
162
|
+
assert_equal("2\n", render("= 1+1"))
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_haml_options
|
166
|
+
Haml::Template.options = { :suppress_eval => true }
|
167
|
+
assert_equal({ :suppress_eval => true }, Haml::Template.options)
|
168
|
+
old_base, @base = @base, create_base
|
169
|
+
assert_renders_correctly("eval_suppressed")
|
170
|
+
@base = old_base
|
171
|
+
Haml::Template.options = {}
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_exceptions_should_work_correctly
|
175
|
+
begin
|
176
|
+
render("- raise 'oops!'")
|
177
|
+
rescue Exception => e
|
178
|
+
assert_equal("oops!", e.message)
|
179
|
+
assert_match(/^\(haml\):1/, e.backtrace[0])
|
180
|
+
else
|
181
|
+
assert false
|
182
|
+
end
|
183
|
+
|
184
|
+
template = <<END
|
185
|
+
%p
|
186
|
+
%h1 Hello!
|
187
|
+
= "lots of lines"
|
188
|
+
= "even more!"
|
189
|
+
- raise 'oh no!'
|
190
|
+
%p
|
191
|
+
this is after the exception
|
192
|
+
%strong yes it is!
|
193
|
+
ho ho ho.
|
194
|
+
END
|
195
|
+
|
196
|
+
begin
|
197
|
+
render(template.chomp)
|
198
|
+
rescue Exception => e
|
199
|
+
assert_match(/^\(haml\):5/, e.backtrace[0])
|
200
|
+
else
|
201
|
+
assert false
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|