haml-edge 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/EDGE_GEM_VERSION +1 -0
- data/FAQ +138 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +332 -0
- data/REVISION +1 -0
- data/Rakefile +226 -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/edge_gem_watch.rb +13 -0
- data/extra/haml-mode.el +596 -0
- data/extra/sass-mode.el +200 -0
- data/init.rb +8 -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 +275 -0
- data/lib/haml/helpers/action_view_extensions.rb +45 -0
- data/lib/haml/helpers/action_view_mods.rb +181 -0
- data/lib/haml/helpers.rb +488 -0
- data/lib/haml/html.rb +222 -0
- data/lib/haml/precompiler.rb +904 -0
- data/lib/haml/shared.rb +45 -0
- data/lib/haml/template/patch.rb +58 -0
- data/lib/haml/template/plugin.rb +72 -0
- data/lib/haml/template.rb +42 -0
- data/lib/haml/util.rb +88 -0
- data/lib/haml/version.rb +47 -0
- data/lib/haml.rb +1044 -0
- data/lib/sass/css.rb +388 -0
- data/lib/sass/engine.rb +495 -0
- data/lib/sass/environment.rb +46 -0
- data/lib/sass/error.rb +35 -0
- data/lib/sass/plugin/merb.rb +56 -0
- data/lib/sass/plugin/rails.rb +24 -0
- data/lib/sass/plugin.rb +204 -0
- data/lib/sass/repl.rb +51 -0
- data/lib/sass/script/bool.rb +13 -0
- data/lib/sass/script/color.rb +97 -0
- data/lib/sass/script/funcall.rb +29 -0
- data/lib/sass/script/functions.rb +134 -0
- data/lib/sass/script/lexer.rb +148 -0
- data/lib/sass/script/literal.rb +82 -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 +9 -0
- data/lib/sass/script/unary_operation.rb +21 -0
- data/lib/sass/script/variable.rb +20 -0
- data/lib/sass/script.rb +38 -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 +35 -0
- data/lib/sass/tree/node.rb +99 -0
- data/lib/sass/tree/rule_node.rb +161 -0
- data/lib/sass/tree/variable_node.rb +24 -0
- data/lib/sass/tree/while_node.rb +21 -0
- data/lib/sass.rb +1062 -0
- data/rails/init.rb +1 -0
- data/test/benchmark.rb +99 -0
- data/test/haml/engine_test.rb +795 -0
- data/test/haml/helper_test.rb +228 -0
- data/test/haml/html2haml_test.rb +108 -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 +162 -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/haml/util_test.rb +87 -0
- data/test/linked_rails.rb +12 -0
- data/test/sass/css2sass_test.rb +193 -0
- data/test/sass/engine_test.rb +709 -0
- data/test/sass/functions_test.rb +109 -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 +213 -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 +250 -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 +278 -0
@@ -0,0 +1,193 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
3
|
+
require 'sass/css'
|
4
|
+
|
5
|
+
class CSS2SassTest < Test::Unit::TestCase
|
6
|
+
def test_basic
|
7
|
+
css = <<CSS
|
8
|
+
h1 {
|
9
|
+
color: red;
|
10
|
+
}
|
11
|
+
CSS
|
12
|
+
assert_equal(<<SASS, css2sass(css))
|
13
|
+
h1
|
14
|
+
:color red
|
15
|
+
SASS
|
16
|
+
assert_equal(<<SASS, css2sass(css, :alternate => true))
|
17
|
+
h1
|
18
|
+
color: red
|
19
|
+
SASS
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_nesting
|
23
|
+
assert_equal(<<SASS, css2sass(<<CSS))
|
24
|
+
li
|
25
|
+
:display none
|
26
|
+
|
27
|
+
a
|
28
|
+
:text-decoration none
|
29
|
+
|
30
|
+
span
|
31
|
+
:color yellow
|
32
|
+
|
33
|
+
&:hover
|
34
|
+
:text-decoration underline
|
35
|
+
SASS
|
36
|
+
li {
|
37
|
+
display: none;
|
38
|
+
}
|
39
|
+
|
40
|
+
li a {
|
41
|
+
text-decoration: none;
|
42
|
+
}
|
43
|
+
|
44
|
+
li a span {
|
45
|
+
color: yellow;
|
46
|
+
}
|
47
|
+
|
48
|
+
li a:hover {
|
49
|
+
text-decoration: underline;
|
50
|
+
}
|
51
|
+
CSS
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_comments_multiline
|
55
|
+
css = <<CSS
|
56
|
+
/* comment */
|
57
|
+
elephant.rawr {
|
58
|
+
rampages: excessively;
|
59
|
+
}
|
60
|
+
|
61
|
+
/* actual multiline
|
62
|
+
comment */
|
63
|
+
span.turkey {
|
64
|
+
isdinner: true;
|
65
|
+
}
|
66
|
+
|
67
|
+
.turducken {
|
68
|
+
/* Sounds funny
|
69
|
+
doesn't it */
|
70
|
+
chimera: not_really;
|
71
|
+
}
|
72
|
+
|
73
|
+
#overhere {
|
74
|
+
bored: sorta; /* it's for a good
|
75
|
+
cause */
|
76
|
+
better_than: thread_pools;
|
77
|
+
}
|
78
|
+
|
79
|
+
#one_more {
|
80
|
+
finally: srsly;
|
81
|
+
} /* just a line here */
|
82
|
+
CSS
|
83
|
+
sass = <<SASS
|
84
|
+
elephant.rawr
|
85
|
+
:rampages excessively
|
86
|
+
|
87
|
+
|
88
|
+
span.turkey
|
89
|
+
:isdinner true
|
90
|
+
|
91
|
+
|
92
|
+
.turducken
|
93
|
+
:chimera not_really
|
94
|
+
|
95
|
+
|
96
|
+
#overhere
|
97
|
+
:bored sorta
|
98
|
+
:better_than thread_pools
|
99
|
+
|
100
|
+
|
101
|
+
#one_more
|
102
|
+
:finally srsly
|
103
|
+
SASS
|
104
|
+
assert_equal(css2sass(css), sass)
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_fold_commas
|
108
|
+
assert_equal(<<SASS, css2sass(<<CSS))
|
109
|
+
li
|
110
|
+
.one, .two
|
111
|
+
:color red
|
112
|
+
SASS
|
113
|
+
li .one {
|
114
|
+
color: red;
|
115
|
+
}
|
116
|
+
li .two {
|
117
|
+
color: red;
|
118
|
+
}
|
119
|
+
CSS
|
120
|
+
|
121
|
+
assert_equal(<<SASS, css2sass(<<CSS))
|
122
|
+
.one
|
123
|
+
:color green
|
124
|
+
|
125
|
+
|
126
|
+
.two
|
127
|
+
:color green
|
128
|
+
:color red
|
129
|
+
|
130
|
+
|
131
|
+
.three
|
132
|
+
:color red
|
133
|
+
SASS
|
134
|
+
.one, .two {
|
135
|
+
color: green;
|
136
|
+
}
|
137
|
+
|
138
|
+
.two, .three {
|
139
|
+
color: red;
|
140
|
+
}
|
141
|
+
CSS
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_bad_formatting
|
145
|
+
assert_equal(<<SASS, css2sass(<<CSS))
|
146
|
+
hello
|
147
|
+
:parent true
|
148
|
+
|
149
|
+
there
|
150
|
+
:parent false
|
151
|
+
|
152
|
+
who
|
153
|
+
:hoo false
|
154
|
+
|
155
|
+
why
|
156
|
+
:y true
|
157
|
+
|
158
|
+
when
|
159
|
+
:wen nao
|
160
|
+
|
161
|
+
|
162
|
+
down_here
|
163
|
+
:yeah true
|
164
|
+
SASS
|
165
|
+
hello {
|
166
|
+
parent: true;
|
167
|
+
}
|
168
|
+
|
169
|
+
hello there {
|
170
|
+
parent: false;
|
171
|
+
}
|
172
|
+
hello who {
|
173
|
+
hoo: false;
|
174
|
+
}
|
175
|
+
hello why {
|
176
|
+
y: true;
|
177
|
+
}
|
178
|
+
hello when {
|
179
|
+
wen: nao;
|
180
|
+
}
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
down_here { yeah: true; }
|
185
|
+
CSS
|
186
|
+
end
|
187
|
+
|
188
|
+
private
|
189
|
+
|
190
|
+
def css2sass(string, opts={})
|
191
|
+
Sass::CSS.new(string, opts).render
|
192
|
+
end
|
193
|
+
end
|