drnic-haml 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. data/.yardopts +5 -0
  2. data/CONTRIBUTING +4 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.md +347 -0
  5. data/REVISION +1 -0
  6. data/Rakefile +371 -0
  7. data/VERSION +1 -0
  8. data/VERSION_NAME +1 -0
  9. data/bin/css2sass +7 -0
  10. data/bin/haml +9 -0
  11. data/bin/html2haml +7 -0
  12. data/bin/sass +8 -0
  13. data/extra/haml-mode.el +663 -0
  14. data/extra/sass-mode.el +205 -0
  15. data/extra/update_watch.rb +13 -0
  16. data/init.rb +8 -0
  17. data/lib/haml.rb +40 -0
  18. data/lib/haml/buffer.rb +307 -0
  19. data/lib/haml/engine.rb +301 -0
  20. data/lib/haml/error.rb +22 -0
  21. data/lib/haml/exec.rb +470 -0
  22. data/lib/haml/filters.rb +341 -0
  23. data/lib/haml/helpers.rb +560 -0
  24. data/lib/haml/helpers/action_view_extensions.rb +40 -0
  25. data/lib/haml/helpers/action_view_mods.rb +176 -0
  26. data/lib/haml/herb.rb +96 -0
  27. data/lib/haml/html.rb +308 -0
  28. data/lib/haml/precompiler.rb +997 -0
  29. data/lib/haml/shared.rb +78 -0
  30. data/lib/haml/template.rb +51 -0
  31. data/lib/haml/template/patch.rb +58 -0
  32. data/lib/haml/template/plugin.rb +71 -0
  33. data/lib/haml/util.rb +244 -0
  34. data/lib/haml/version.rb +64 -0
  35. data/lib/sass.rb +24 -0
  36. data/lib/sass/css.rb +423 -0
  37. data/lib/sass/engine.rb +491 -0
  38. data/lib/sass/environment.rb +79 -0
  39. data/lib/sass/error.rb +162 -0
  40. data/lib/sass/files.rb +133 -0
  41. data/lib/sass/plugin.rb +170 -0
  42. data/lib/sass/plugin/merb.rb +57 -0
  43. data/lib/sass/plugin/rails.rb +23 -0
  44. data/lib/sass/repl.rb +58 -0
  45. data/lib/sass/script.rb +55 -0
  46. data/lib/sass/script/bool.rb +17 -0
  47. data/lib/sass/script/color.rb +183 -0
  48. data/lib/sass/script/funcall.rb +50 -0
  49. data/lib/sass/script/functions.rb +199 -0
  50. data/lib/sass/script/lexer.rb +191 -0
  51. data/lib/sass/script/literal.rb +177 -0
  52. data/lib/sass/script/node.rb +14 -0
  53. data/lib/sass/script/number.rb +381 -0
  54. data/lib/sass/script/operation.rb +45 -0
  55. data/lib/sass/script/parser.rb +222 -0
  56. data/lib/sass/script/string.rb +12 -0
  57. data/lib/sass/script/unary_operation.rb +34 -0
  58. data/lib/sass/script/variable.rb +31 -0
  59. data/lib/sass/tree/comment_node.rb +84 -0
  60. data/lib/sass/tree/debug_node.rb +30 -0
  61. data/lib/sass/tree/directive_node.rb +70 -0
  62. data/lib/sass/tree/for_node.rb +48 -0
  63. data/lib/sass/tree/if_node.rb +54 -0
  64. data/lib/sass/tree/import_node.rb +69 -0
  65. data/lib/sass/tree/mixin_def_node.rb +29 -0
  66. data/lib/sass/tree/mixin_node.rb +48 -0
  67. data/lib/sass/tree/node.rb +252 -0
  68. data/lib/sass/tree/prop_node.rb +106 -0
  69. data/lib/sass/tree/root_node.rb +56 -0
  70. data/lib/sass/tree/rule_node.rb +220 -0
  71. data/lib/sass/tree/variable_node.rb +34 -0
  72. data/lib/sass/tree/while_node.rb +31 -0
  73. data/rails/init.rb +1 -0
  74. data/test/benchmark.rb +99 -0
  75. data/test/haml/engine_test.rb +1129 -0
  76. data/test/haml/helper_test.rb +282 -0
  77. data/test/haml/html2haml_test.rb +258 -0
  78. data/test/haml/markaby/standard.mab +52 -0
  79. data/test/haml/mocks/article.rb +6 -0
  80. data/test/haml/results/content_for_layout.xhtml +12 -0
  81. data/test/haml/results/eval_suppressed.xhtml +9 -0
  82. data/test/haml/results/filters.xhtml +62 -0
  83. data/test/haml/results/helpers.xhtml +93 -0
  84. data/test/haml/results/helpful.xhtml +10 -0
  85. data/test/haml/results/just_stuff.xhtml +68 -0
  86. data/test/haml/results/list.xhtml +12 -0
  87. data/test/haml/results/nuke_inner_whitespace.xhtml +40 -0
  88. data/test/haml/results/nuke_outer_whitespace.xhtml +148 -0
  89. data/test/haml/results/original_engine.xhtml +20 -0
  90. data/test/haml/results/partial_layout.xhtml +5 -0
  91. data/test/haml/results/partials.xhtml +21 -0
  92. data/test/haml/results/render_layout.xhtml +3 -0
  93. data/test/haml/results/silent_script.xhtml +74 -0
  94. data/test/haml/results/standard.xhtml +162 -0
  95. data/test/haml/results/tag_parsing.xhtml +23 -0
  96. data/test/haml/results/very_basic.xhtml +5 -0
  97. data/test/haml/results/whitespace_handling.xhtml +89 -0
  98. data/test/haml/rhtml/_av_partial_1.rhtml +12 -0
  99. data/test/haml/rhtml/_av_partial_2.rhtml +8 -0
  100. data/test/haml/rhtml/action_view.rhtml +62 -0
  101. data/test/haml/rhtml/standard.rhtml +54 -0
  102. data/test/haml/spec_test.rb +44 -0
  103. data/test/haml/template_test.rb +217 -0
  104. data/test/haml/templates/_av_partial_1.haml +9 -0
  105. data/test/haml/templates/_av_partial_1_ugly.haml +9 -0
  106. data/test/haml/templates/_av_partial_2.haml +5 -0
  107. data/test/haml/templates/_av_partial_2_ugly.haml +5 -0
  108. data/test/haml/templates/_layout.erb +3 -0
  109. data/test/haml/templates/_layout_for_partial.haml +3 -0
  110. data/test/haml/templates/_partial.haml +8 -0
  111. data/test/haml/templates/_text_area.haml +3 -0
  112. data/test/haml/templates/action_view.haml +47 -0
  113. data/test/haml/templates/action_view_ugly.haml +47 -0
  114. data/test/haml/templates/breakage.haml +8 -0
  115. data/test/haml/templates/content_for_layout.haml +8 -0
  116. data/test/haml/templates/eval_suppressed.haml +11 -0
  117. data/test/haml/templates/filters.haml +66 -0
  118. data/test/haml/templates/helpers.haml +95 -0
  119. data/test/haml/templates/helpful.haml +11 -0
  120. data/test/haml/templates/just_stuff.haml +83 -0
  121. data/test/haml/templates/list.haml +12 -0
  122. data/test/haml/templates/nuke_inner_whitespace.haml +32 -0
  123. data/test/haml/templates/nuke_outer_whitespace.haml +144 -0
  124. data/test/haml/templates/original_engine.haml +17 -0
  125. data/test/haml/templates/partial_layout.haml +3 -0
  126. data/test/haml/templates/partialize.haml +1 -0
  127. data/test/haml/templates/partials.haml +12 -0
  128. data/test/haml/templates/render_layout.haml +2 -0
  129. data/test/haml/templates/silent_script.haml +40 -0
  130. data/test/haml/templates/standard.haml +42 -0
  131. data/test/haml/templates/standard_ugly.haml +42 -0
  132. data/test/haml/templates/tag_parsing.haml +21 -0
  133. data/test/haml/templates/very_basic.haml +4 -0
  134. data/test/haml/templates/whitespace_handling.haml +87 -0
  135. data/test/haml/util_test.rb +92 -0
  136. data/test/linked_rails.rb +12 -0
  137. data/test/sass/css2sass_test.rb +294 -0
  138. data/test/sass/engine_test.rb +956 -0
  139. data/test/sass/functions_test.rb +126 -0
  140. data/test/sass/more_results/more1.css +9 -0
  141. data/test/sass/more_results/more1_with_line_comments.css +26 -0
  142. data/test/sass/more_results/more_import.css +29 -0
  143. data/test/sass/more_templates/_more_partial.sass +2 -0
  144. data/test/sass/more_templates/more1.sass +23 -0
  145. data/test/sass/more_templates/more_import.sass +11 -0
  146. data/test/sass/plugin_test.rb +229 -0
  147. data/test/sass/results/alt.css +4 -0
  148. data/test/sass/results/basic.css +9 -0
  149. data/test/sass/results/compact.css +5 -0
  150. data/test/sass/results/complex.css +87 -0
  151. data/test/sass/results/compressed.css +1 -0
  152. data/test/sass/results/expanded.css +19 -0
  153. data/test/sass/results/import.css +29 -0
  154. data/test/sass/results/line_numbers.css +49 -0
  155. data/test/sass/results/mixins.css +95 -0
  156. data/test/sass/results/multiline.css +24 -0
  157. data/test/sass/results/nested.css +22 -0
  158. data/test/sass/results/parent_ref.css +13 -0
  159. data/test/sass/results/script.css +16 -0
  160. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
  161. data/test/sass/results/subdir/subdir.css +3 -0
  162. data/test/sass/results/units.css +11 -0
  163. data/test/sass/script_test.rb +261 -0
  164. data/test/sass/templates/_partial.sass +2 -0
  165. data/test/sass/templates/alt.sass +16 -0
  166. data/test/sass/templates/basic.sass +23 -0
  167. data/test/sass/templates/bork1.sass +2 -0
  168. data/test/sass/templates/bork2.sass +2 -0
  169. data/test/sass/templates/bork3.sass +2 -0
  170. data/test/sass/templates/compact.sass +17 -0
  171. data/test/sass/templates/complex.sass +307 -0
  172. data/test/sass/templates/compressed.sass +15 -0
  173. data/test/sass/templates/expanded.sass +17 -0
  174. data/test/sass/templates/import.sass +11 -0
  175. data/test/sass/templates/importee.sass +19 -0
  176. data/test/sass/templates/line_numbers.sass +13 -0
  177. data/test/sass/templates/mixins.sass +76 -0
  178. data/test/sass/templates/multiline.sass +20 -0
  179. data/test/sass/templates/nested.sass +25 -0
  180. data/test/sass/templates/nested_bork1.sass +2 -0
  181. data/test/sass/templates/nested_bork2.sass +2 -0
  182. data/test/sass/templates/nested_bork3.sass +2 -0
  183. data/test/sass/templates/parent_ref.sass +25 -0
  184. data/test/sass/templates/script.sass +101 -0
  185. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
  186. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
  187. data/test/sass/templates/subdir/subdir.sass +6 -0
  188. data/test/sass/templates/units.sass +11 -0
  189. data/test/test_helper.rb +44 -0
  190. metadata +298 -0
@@ -0,0 +1,4 @@
1
+ h1 { float: left; width: 274px; height: 75px; margin: 0; background-repeat: no-repeat; background-image: none; }
2
+ h1 a:hover, h1 a:visited { color: green; }
3
+ h1 b:hover { color: red; background-color: green; }
4
+ h1 const { nosp: 3; sp: 3; }
@@ -0,0 +1,9 @@
1
+ body { font: Arial; background: blue; }
2
+
3
+ #page { width: 700px; height: 100; }
4
+ #page #header { height: 300px; }
5
+ #page #header h1 { font-size: 50px; color: blue; }
6
+
7
+ #content.user.show #container.top #column.left { width: 100px; }
8
+ #content.user.show #container.top #column.right { width: 600px; }
9
+ #content.user.show #container.bottom { background: brown; }
@@ -0,0 +1,5 @@
1
+ #main { width: 15em; color: #0000ff; }
2
+ #main p { border-style: dotted; /* Nested comment More nested stuff */ border-width: 2px; }
3
+ #main .cool { width: 100px; }
4
+
5
+ #left { font-size: 2em; font-weight: bold; float: left; }
@@ -0,0 +1,87 @@
1
+ body { margin: 0; font: 0.85em "Lucida Grande", "Trebuchet MS", Verdana, sans-serif; color: #fff; background: url(/images/global_bg.gif); }
2
+
3
+ #page { width: 900px; margin: 0 auto; background: #440008; border-top-width: 5px; border-top-style: solid; border-top-color: #ff8500; }
4
+
5
+ #header { height: 75px; padding: 0; }
6
+ #header h1 { float: left; width: 274px; height: 75px; margin: 0; background-image: url(/images/global_logo.gif); /* Crazy nested comment */ background-repeat: no-repeat; text-indent: -9999px; }
7
+ #header .status { float: right; padding-top: .5em; padding-left: .5em; padding-right: .5em; padding-bottom: 0; }
8
+ #header .status p { float: left; margin-top: 0; margin-right: 0.5em; margin-bottom: 0; margin-left: 0; }
9
+ #header .status ul { float: left; margin: 0; padding: 0; }
10
+ #header .status li { list-style-type: none; display: inline; margin: 0 5px; }
11
+ #header .status a:link, #header .status a:visited { color: #ff8500; text-decoration: none; }
12
+ #header .status a:hover { text-decoration: underline; }
13
+ #header .search { float: right; clear: right; margin: 12px 0 0 0; }
14
+ #header .search form { margin: 0; }
15
+ #header .search input { margin: 0 3px 0 0; padding: 2px; border: none; }
16
+
17
+ #menu { clear: both; text-align: right; height: 20px; border-bottom: 5px solid #006b95; background: #00a4e4; }
18
+ #menu .contests ul { margin: 0 5px 0 0; padding: 0; }
19
+ #menu .contests ul li { list-style-type: none; margin: 0 5px; padding: 5px 5px 0 5px; display: inline; font-size: 1.1em; color: #fff; background: #00a4e4; }
20
+ #menu .contests ul li / This rule isn't a comment! { red: green; }
21
+ #menu .contests a:link, #menu .contests a:visited { color: #fff; text-decoration: none; font-weight: bold; }
22
+ #menu .contests a:hover { text-decoration: underline; }
23
+
24
+ #content { clear: both; }
25
+ #content .container { clear: both; }
26
+ #content .container .column { float: left; }
27
+ #content .container .column .right { float: right; }
28
+ #content a:link, #content a:visited { color: #93d700; text-decoration: none; }
29
+ #content a:hover { text-decoration: underline; }
30
+
31
+ #content p, #content div { width: 40em; }
32
+ #content p li, #content p dt, #content p dd, #content div li, #content div dt, #content div dd { color: #ddffdd; background-color: #4792bb; }
33
+ #content .container.video .column.left { width: 200px; }
34
+ #content .container.video .column.left .box { margin-top: 10px; }
35
+ #content .container.video .column.left .box p { margin: 0 1em auto 1em; }
36
+ #content .container.video .column.left .box.participants img { float: left; margin: 0 1em auto 1em; border: 1px solid #6e000d; border-style: solid; }
37
+ #content .container.video .column.left .box.participants h2 { margin: 0 0 10px 0; padding: 0.5em; /* The background image is a gif! */ background: #6e000d url(/images/hdr_participant.gif) 2px 2px no-repeat; /* Okay check this out Multiline comments Wow dude I mean seriously, WOW */ text-indent: -9999px; border-top-width: 5px; border-top-style: solid; border-top-color: #a20013; border-right-width: 1px; border-right-style: dotted; }
38
+ #content .container.video .column.middle { width: 500px; }
39
+ #content .container.video .column.right { width: 200px; }
40
+ #content .container.video .column.right .box { margin-top: 0; }
41
+ #content .container.video .column.right .box p { margin: 0 1em auto 1em; }
42
+ #content .container.video .column p { margin-top: 0; }
43
+
44
+ #content.contests .container.information .column.right .box { margin: 1em 0; }
45
+ #content.contests .container.information .column.right .box.videos .thumbnail img { width: 200px; height: 150px; margin-bottom: 5px; }
46
+ #content.contests .container.information .column.right .box.videos a:link, #content.contests .container.information .column.right .box.videos a:visited { color: #93d700; text-decoration: none; }
47
+ #content.contests .container.information .column.right .box.videos a:hover { text-decoration: underline; }
48
+ #content.contests .container.information .column.right .box.votes a { display: block; width: 200px; height: 60px; margin: 15px 0; background: url(/images/btn_votenow.gif) no-repeat; text-indent: -9999px; outline: none; border: none; }
49
+ #content.contests .container.information .column.right .box.votes h2 { margin: 52px 0 10px 0; padding: 0.5em; background: #6e000d url(/images/hdr_videostats.gif) 2px 2px no-repeat; text-indent: -9999px; border-top: 5px solid #a20013; }
50
+
51
+ #content.contests .container.video .box.videos h2 { margin: 0; padding: 0.5em; background: #6e000d url(/images/hdr_newestclips.gif) 2px 2px no-repeat; text-indent: -9999px; border-top: 5px solid #a20013; }
52
+ #content.contests .container.video .box.videos table { width: 100; }
53
+ #content.contests .container.video .box.videos table td { padding: 1em; width: 25; vertical-align: top; }
54
+ #content.contests .container.video .box.videos table td p { margin: 0 0 5px 0; }
55
+ #content.contests .container.video .box.videos table td a:link, #content.contests .container.video .box.videos table td a:visited { color: #93d700; text-decoration: none; }
56
+ #content.contests .container.video .box.videos table td a:hover { text-decoration: underline; }
57
+ #content.contests .container.video .box.videos .thumbnail { float: left; }
58
+ #content.contests .container.video .box.videos .thumbnail img { width: 80px; height: 60px; margin: 0 10px 0 0; border: 1px solid #6e000d; }
59
+
60
+ #content .container.comments .column { margin-top: 15px; }
61
+ #content .container.comments .column.left { width: 600px; }
62
+ #content .container.comments .column.left .box ol { margin: 0; padding: 0; }
63
+ #content .container.comments .column.left .box li { list-style-type: none; padding: 10px; margin: 0 0 1em 0; background: #6e000d; border-top: 5px solid #a20013; }
64
+ #content .container.comments .column.left .box li div { margin-bottom: 1em; }
65
+ #content .container.comments .column.left .box li ul { text-align: right; }
66
+ #content .container.comments .column.left .box li ul li { display: inline; border: none; padding: 0; }
67
+ #content .container.comments .column.right { width: 290px; padding-left: 10px; }
68
+ #content .container.comments .column.right h2 { margin: 0; padding: 0.5em; background: #6e000d url(/images/hdr_addcomment.gif) 2px 2px no-repeat; text-indent: -9999px; border-top: 5px solid #a20013; }
69
+ #content .container.comments .column.right .box textarea { width: 290px; height: 100px; border: none; }
70
+
71
+ #footer { margin-top: 10px; padding: 1.2em 1.5em; background: #ff8500; }
72
+ #footer ul { margin: 0; padding: 0; list-style-type: none; }
73
+ #footer ul li { display: inline; margin: 0 0.5em; color: #440008; }
74
+ #footer ul.links { float: left; }
75
+ #footer ul.links a:link, #footer ul.links a:visited { color: #440008; text-decoration: none; }
76
+ #footer ul.links a:hover { text-decoration: underline; }
77
+ #footer ul.copyright { float: right; }
78
+
79
+ .clear { clear: both; }
80
+
81
+ .centered { text-align: center; }
82
+
83
+ img { border: none; }
84
+
85
+ button.short { width: 60px; height: 22px; padding: 0 0 2px 0; color: #fff; border: none; background: url(/images/btn_short.gif) no-repeat; }
86
+
87
+ table { border-collapse: collapse; }
@@ -0,0 +1 @@
1
+ #main{width:15em;color:#0000ff}#main p{border-style:dotted;border-width:2px}#main .cool{width:100px}#left{font-size:2em;font-weight:bold;float:left}
@@ -0,0 +1,19 @@
1
+ #main {
2
+ width: 15em;
3
+ color: #0000ff;
4
+ }
5
+ #main p {
6
+ border-style: dotted;
7
+ /* Nested comment
8
+ * More nested stuff */
9
+ border-width: 2px;
10
+ }
11
+ #main .cool {
12
+ width: 100px;
13
+ }
14
+
15
+ #left {
16
+ font-size: 2em;
17
+ font-weight: bold;
18
+ float: left;
19
+ }
@@ -0,0 +1,29 @@
1
+ imported { otherconst: hello; myconst: goodbye; pre-mixin: here; }
2
+
3
+ body { font: Arial; background: blue; }
4
+
5
+ #page { width: 700px; height: 100; }
6
+ #page #header { height: 300px; }
7
+ #page #header h1 { font-size: 50px; color: blue; }
8
+
9
+ #content.user.show #container.top #column.left { width: 100px; }
10
+ #content.user.show #container.top #column.right { width: 600px; }
11
+ #content.user.show #container.bottom { background: brown; }
12
+
13
+ midrule { inthe: middle; }
14
+
15
+ body { font: Arial; background: blue; }
16
+
17
+ #page { width: 700px; height: 100; }
18
+ #page #header { height: 300px; }
19
+ #page #header h1 { font-size: 50px; color: blue; }
20
+
21
+ #content.user.show #container.top #column.left { width: 100px; }
22
+ #content.user.show #container.top #column.right { width: 600px; }
23
+ #content.user.show #container.bottom { background: brown; }
24
+
25
+ @import url(basic.css);
26
+ @import url(../results/complex.css);
27
+ #foo { background-color: #baf; }
28
+
29
+ nonimported { myconst: hello; otherconst: goodbye; post-mixin: here; }
@@ -0,0 +1,49 @@
1
+ /* line 1, ../templates/line_numbers.sass */
2
+ foo {
3
+ bar: baz; }
4
+
5
+ /* line 6, ../templates/importee.sass */
6
+ imported {
7
+ otherconst: 12;
8
+ myconst: goodbye; }
9
+ /* line 5, ../templates/line_numbers.sass */
10
+ imported squggle {
11
+ blat: bang; }
12
+
13
+ /* line 3, ../templates/basic.sass */
14
+ body {
15
+ font: Arial;
16
+ background: blue; }
17
+
18
+ /* line 7, ../templates/basic.sass */
19
+ #page {
20
+ width: 700px;
21
+ height: 100; }
22
+ /* line 10, ../templates/basic.sass */
23
+ #page #header {
24
+ height: 300px; }
25
+ /* line 12, ../templates/basic.sass */
26
+ #page #header h1 {
27
+ font-size: 50px;
28
+ color: blue; }
29
+
30
+ /* line 18, ../templates/basic.sass */
31
+ #content.user.show #container.top #column.left {
32
+ width: 100px; }
33
+ /* line 20, ../templates/basic.sass */
34
+ #content.user.show #container.top #column.right {
35
+ width: 600px; }
36
+ /* line 22, ../templates/basic.sass */
37
+ #content.user.show #container.bottom {
38
+ background: brown; }
39
+
40
+ /* line 13, ../templates/importee.sass */
41
+ midrule {
42
+ inthe: middle; }
43
+
44
+ /* line 12, ../templates/line_numbers.sass */
45
+ umph {
46
+ foo: bar; }
47
+ /* line 18, ../templates/importee.sass */
48
+ umph baz {
49
+ blat: bang; }
@@ -0,0 +1,95 @@
1
+ #main {
2
+ width: 15em;
3
+ color: #0000ff;
4
+ }
5
+ #main p {
6
+ border-top-width: 2px;
7
+ border-top-color: #ffcc00;
8
+ border-left-width: 1px;
9
+ border-left-color: #000;
10
+ -moz-border-radius: 10px;
11
+ border-style: dotted;
12
+ border-width: 2px;
13
+ }
14
+ #main .cool {
15
+ width: 100px;
16
+ }
17
+
18
+ #left {
19
+ border-top-width: 2px;
20
+ border-top-color: #ffcc00;
21
+ border-left-width: 1px;
22
+ border-left-color: #000;
23
+ -moz-border-radius: 10px;
24
+ font-size: 2em;
25
+ font-weight: bold;
26
+ float: left;
27
+ }
28
+
29
+ #right {
30
+ border-top-width: 2px;
31
+ border-top-color: #ffcc00;
32
+ border-left-width: 1px;
33
+ border-left-color: #000;
34
+ -moz-border-radius: 10px;
35
+ color: #f00;
36
+ font-size: 20px;
37
+ float: right;
38
+ }
39
+
40
+ .bordered {
41
+ border-top-width: 2px;
42
+ border-top-color: #ffcc00;
43
+ border-left-width: 1px;
44
+ border-left-color: #000;
45
+ -moz-border-radius: 10px;
46
+ }
47
+
48
+ .complex {
49
+ color: #f00;
50
+ font-size: 20px;
51
+ text-decoration: none;
52
+ }
53
+ .complex:after {
54
+ content: ".";
55
+ display: block;
56
+ height: 0;
57
+ clear: both;
58
+ visibility: hidden;
59
+ }
60
+ * html .complex {
61
+ height: 1px;
62
+ color: #f00;
63
+ font-size: 20px;
64
+ }
65
+
66
+ .more-complex {
67
+ color: #f00;
68
+ font-size: 20px;
69
+ text-decoration: none;
70
+ display: inline;
71
+ -webkit-nonsense-top-right: 1px;
72
+ -webkit-nonsense-bottom-left: 1px;
73
+ }
74
+ .more-complex:after {
75
+ content: ".";
76
+ display: block;
77
+ height: 0;
78
+ clear: both;
79
+ visibility: hidden;
80
+ }
81
+ * html .more-complex {
82
+ height: 1px;
83
+ color: #f00;
84
+ font-size: 20px;
85
+ }
86
+ .more-complex a:hover {
87
+ text-decoration: underline;
88
+ color: #f00;
89
+ font-size: 20px;
90
+ border-top-width: 2px;
91
+ border-top-color: #ffcc00;
92
+ border-left-width: 1px;
93
+ border-left-color: #000;
94
+ -moz-border-radius: 10px;
95
+ }
@@ -0,0 +1,24 @@
1
+ #main,
2
+ #header {
3
+ height: 50px; }
4
+ #main div,
5
+ #header div {
6
+ width: 100px; }
7
+ #main div a span,
8
+ #main div em span,
9
+ #header div a span,
10
+ #header div em span {
11
+ color: pink; }
12
+
13
+ #one div.nested,
14
+ #one span.nested,
15
+ #one p.nested,
16
+ #two div.nested,
17
+ #two span.nested,
18
+ #two p.nested,
19
+ #three div.nested,
20
+ #three span.nested,
21
+ #three p.nested {
22
+ font-weight: bold;
23
+ border-color: red;
24
+ display: block; }
@@ -0,0 +1,22 @@
1
+ #main {
2
+ width: 15em;
3
+ color: #0000ff; }
4
+ #main p {
5
+ border-style: dotted;
6
+ /* Nested comment
7
+ * More nested stuff */
8
+ border-width: 2px; }
9
+ #main .cool {
10
+ width: 100px; }
11
+
12
+ #left {
13
+ font-size: 2em;
14
+ font-weight: bold;
15
+ float: left; }
16
+
17
+ #right .header {
18
+ border-style: solid; }
19
+ #right .body {
20
+ border-style: dotted; }
21
+ #right .footer {
22
+ border-style: dashed; }
@@ -0,0 +1,13 @@
1
+ a { color: #000; }
2
+ a:hover { color: #f00; }
3
+
4
+ p, div { width: 100em; }
5
+ p foo, div foo { width: 10em; }
6
+ p:hover, p bar, div:hover, div bar { height: 20em; }
7
+
8
+ #cool { border-style: solid; border-width: 2em; }
9
+ .ie7 #cool, .ie6 #cool { content: string(Totally not cool.); }
10
+ .firefox #cool { content: string(Quite cool.); }
11
+
12
+ .wow, .snazzy { font-family: fantasy; }
13
+ .wow:hover, .wow:visited, .snazzy:hover, .snazzy:visited { font-weight: bold; }
@@ -0,0 +1,16 @@
1
+ #main { content: Hello!; qstr: Quo"ted"!; hstr: Hyph-en!; width: 30em; background-color: #000; color: #ffffaa; short-color: #112233; named-color: olive; con: foo bar(9 hi there boom); con2: noquo quo; }
2
+ #main #sidebar { background-color: #00ff98; num-normal: 10; num-dec: 10.2; num-dec0: 99; num-neg: -10; esc: 10 +12; many: 6; order: 7; complex: #4c9db1hi16; }
3
+
4
+ #plus { num-num: 7; num-num-un: 25em; num-num-un2: 23em; num-num-neg: 9.87; num-str: 100px; num-col: #b7b7b7; num-perc: 31%; str-str: hi there; str-str2: hi there; str-col: 14em solid #112233; str-num: times: 13; col-num: #ff7b9d; col-col: #5173ff; }
5
+
6
+ #minus { num-num: 900; col-num: #f9f9f4; col-col: #000035; unary-num: -1; unary-const: 10; unary-paren: -11; unary-two: 12; unary-many: 12; unary-crazy: -15; }
7
+
8
+ #times { num-num: 7; num-col: #7496b8; col-num: #092345; col-col: #243648; }
9
+
10
+ #div { num-num: 3.333; num-num2: 3.333; col-num: #092345; col-col: #0b0d0f; comp: 1px; }
11
+
12
+ #mod { num-num: 2; col-col: #0f0e05; col-num: #020001; }
13
+
14
+ #const { escaped-quote: !foo; default: Hello! !important; }
15
+
16
+ #regression { a: 4; }
@@ -0,0 +1 @@
1
+ #pi { width: 314px; }
@@ -0,0 +1,3 @@
1
+ #nested { relative: true; }
2
+
3
+ #subdir { font-size: 20px; font-weight: bold; }
@@ -0,0 +1,11 @@
1
+ b {
2
+ foo: 5px;
3
+ bar: 24px;
4
+ baz: 66.667%;
5
+ many-units: 32em;
6
+ mm: 15mm;
7
+ pc: 2pc;
8
+ pt: -72pt;
9
+ inches: 2in;
10
+ more-inches: 3.5in;
11
+ mixed: 6px; }
@@ -0,0 +1,261 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../test_helper'
3
+ require 'sass/engine'
4
+
5
+ class SassScriptTest < Test::Unit::TestCase
6
+ include Sass::Script
7
+
8
+ def test_color_checks_input
9
+ assert_raise(Sass::SyntaxError, "Color values must be between 0 and 255") {Color.new([1, 2, -1])}
10
+ assert_raise(Sass::SyntaxError, "Color values must be between 0 and 255") {Color.new([256, 2, 3])}
11
+ end
12
+
13
+ def test_string_escapes
14
+ assert_equal '"', resolve("\"\\\"\"")
15
+ assert_equal "\\", resolve("\"\\\\\"")
16
+ assert_equal "\\02fa", resolve("\"\\02fa\"")
17
+ end
18
+
19
+ def test_color_names
20
+ assert_equal "white", resolve("white")
21
+ assert_equal "white", resolve("#ffffff")
22
+ assert_equal "#fffffe", resolve("white - #000001")
23
+ end
24
+
25
+ def test_implicit_strings
26
+ silence_warnings do
27
+ assert_equal Sass::Script::String.new("foo"), eval("foo")
28
+ assert_equal Sass::Script::String.new("foo bar"), eval("foo bar")
29
+ assert_equal Sass::Script::String.new("foo/bar"), eval("foo/bar")
30
+ end
31
+ end
32
+
33
+ def test_interpolation
34
+ assert_equal "foo bar, baz bang", resolve('"foo #{"bar"}, #{"baz"} bang"')
35
+ assert_equal "foo bar baz bang", resolve('"foo #{"#{"ba" + "r"} baz"} bang"')
36
+ assert_equal 'foo #{bar baz} bang', resolve('"foo \#{#{"ba" + "r"} baz} bang"')
37
+ assert_equal 'foo #{baz bang', resolve('"foo #{"\#{" + "baz"} bang"')
38
+ end
39
+
40
+ def test_rule_interpolation
41
+ assert_equal(<<CSS, render(<<SASS))
42
+ foo bar baz bang {
43
+ a: b; }
44
+ CSS
45
+ foo \#{"\#{"ba" + "r"} baz"} bang
46
+ a: b
47
+ SASS
48
+ assert_equal(<<CSS, render(<<SASS))
49
+ foo \#{bar baz} bang {
50
+ a: b; }
51
+ CSS
52
+ foo \\\#{\#{"ba" + "r"} baz} bang
53
+ a: b
54
+ SASS
55
+ assert_equal(<<CSS, render(<<SASS))
56
+ foo \#{baz bang {
57
+ a: b; }
58
+ CSS
59
+ foo \#{"\\\#{" + "baz"} bang
60
+ a: b
61
+ SASS
62
+ end
63
+
64
+ def test_implicit_string_warning
65
+ assert_warning(<<WARN) {eval("foo")}
66
+ DEPRECATION WARNING:
67
+ On line 1, character 1 of 'test_implicit_string_warning_inline.sass'
68
+ Implicit strings have been deprecated and will be removed in version 2.4.
69
+ 'foo' was not quoted. Please add double quotes (e.g. "foo").
70
+ WARN
71
+ assert_warning(<<WARN) {eval("1 + foo")}
72
+ DEPRECATION WARNING:
73
+ On line 1, character 5 of 'test_implicit_string_warning_inline.sass'
74
+ Implicit strings have been deprecated and will be removed in version 2.4.
75
+ 'foo' was not quoted. Please add double quotes (e.g. "foo").
76
+ WARN
77
+ assert_warning(<<WARN) {render("@if 1 + foo")}
78
+ DEPRECATION WARNING:
79
+ On line 1, character 9 of 'test_implicit_string_warning_inline.sass'
80
+ Implicit strings have been deprecated and will be removed in version 2.4.
81
+ 'foo' was not quoted. Please add double quotes (e.g. "foo").
82
+ WARN
83
+
84
+ # Regression
85
+ assert_warning(<<WARN) {render("@if if")}
86
+ DEPRECATION WARNING:
87
+ On line 1, character 5 of 'test_implicit_string_warning_inline.sass'
88
+ Implicit strings have been deprecated and will be removed in version 2.4.
89
+ 'if' was not quoted. Please add double quotes (e.g. "if").
90
+ WARN
91
+ end
92
+
93
+ def test_inaccessible_functions
94
+ assert_warning <<WARN do
95
+ DEPRECATION WARNING:
96
+ On line 2, character 6 of 'test_inaccessible_functions_inline.sass'
97
+ Implicit strings have been deprecated and will be removed in version 2.4.
98
+ 'to_s' was not quoted. Please add double quotes (e.g. "to_s").
99
+ WARN
100
+ assert_equal "send(to_s)", resolve("send(to_s)", :line => 2)
101
+ end
102
+ assert_equal "public_instance_methods()", resolve("public_instance_methods()")
103
+ end
104
+
105
+ def test_hyphen_warning
106
+ a = Sass::Script::String.new("a")
107
+ b = Sass::Script::String.new("b")
108
+ assert_warning(<<WARN) {eval("!a-!b", {}, env("a" => a, "b" => b))}
109
+ DEPRECATION WARNING:
110
+ On line 1, character 3 of 'test_hyphen_warning_inline.sass'
111
+ - will be allowed as part of variable names in version 2.4.
112
+ Please add whitespace to separate it from the previous token.
113
+ WARN
114
+
115
+ assert_warning(<<WARN) {eval("true-false")}
116
+ DEPRECATION WARNING:
117
+ On line 1, character 5 of 'test_hyphen_warning_inline.sass'
118
+ - will be allowed as part of variable names in version 2.4.
119
+ Please add whitespace to separate it from the previous token.
120
+ WARN
121
+ end
122
+
123
+ def test_ruby_equality
124
+ assert_equal eval('"foo"'), eval('"foo"')
125
+ assert_equal eval('1'), eval('1.0')
126
+ assert_not_equal eval('1'), eval('"1"')
127
+ end
128
+
129
+ def test_booleans
130
+ assert_equal "true", resolve("true")
131
+ assert_equal "false", resolve("false")
132
+ end
133
+
134
+ def test_boolean_ops
135
+ assert_equal "true", resolve("true and true")
136
+ assert_equal "true", resolve("false or true")
137
+ assert_equal "true", resolve("true or false")
138
+ assert_equal "true", resolve("true or true")
139
+ assert_equal "false", resolve("false or false")
140
+ assert_equal "false", resolve("false and true")
141
+ assert_equal "false", resolve("true and false")
142
+ assert_equal "false", resolve("false and false")
143
+
144
+ assert_equal "true", resolve("not false")
145
+ assert_equal "false", resolve("not true")
146
+ assert_equal "true", resolve("not not true")
147
+
148
+ assert_equal "1", resolve("false or 1")
149
+ assert_equal "false", resolve("false and 1")
150
+ assert_equal "2", resolve("2 or 3")
151
+ assert_equal "3", resolve("2 and 3")
152
+ end
153
+
154
+ def test_arithmetic_ops
155
+ assert_equal "2", resolve("1 + 1")
156
+ assert_equal "0", resolve("1 - 1")
157
+ assert_equal "8", resolve("2 * 4")
158
+ assert_equal "0.5", resolve("2 / 4")
159
+ assert_equal "2", resolve("4 / 2")
160
+
161
+ assert_equal "-1", resolve("-1")
162
+ end
163
+
164
+ def test_string_ops
165
+ assert_equal "foo bar", resolve('"foo" "bar"')
166
+ assert_equal "true 1", resolve('true 1')
167
+ assert_equal "foo, bar", resolve('"foo" , "bar"')
168
+ assert_equal "true, 1", resolve('true , 1')
169
+ assert_equal "foobar", resolve('"foo" + "bar"')
170
+ assert_equal "true1", resolve('true + 1')
171
+ assert_equal "foo-bar", resolve('"foo" - "bar"')
172
+ assert_equal "true-1", resolve('true - 1')
173
+ assert_equal "foo/bar", resolve('"foo" / "bar"')
174
+ assert_equal "true/1", resolve('true / 1')
175
+
176
+ assert_equal "-bar", resolve('- "bar"')
177
+ assert_equal "-true", resolve('- true')
178
+ assert_equal "/bar", resolve('/ "bar"')
179
+ assert_equal "/true", resolve('/ true')
180
+ end
181
+
182
+ def test_relational_ops
183
+ assert_equal "false", resolve("1 > 2")
184
+ assert_equal "false", resolve("2 > 2")
185
+ assert_equal "true", resolve("3 > 2")
186
+ assert_equal "false", resolve("1 >= 2")
187
+ assert_equal "true", resolve("2 >= 2")
188
+ assert_equal "true", resolve("3 >= 2")
189
+ assert_equal "true", resolve("1 < 2")
190
+ assert_equal "false", resolve("2 < 2")
191
+ assert_equal "false", resolve("3 < 2")
192
+ assert_equal "true", resolve("1 <= 2")
193
+ assert_equal "true", resolve("2 <= 2")
194
+ assert_equal "false", resolve("3 <= 2")
195
+ end
196
+
197
+ def test_equals
198
+ assert_equal("true", resolve('"foo" == !foo', {},
199
+ env("foo" => Sass::Script::String.new("foo"))))
200
+ assert_equal "true", resolve("1 == 1.0")
201
+ assert_equal "true", resolve("false != true")
202
+ assert_equal "false", resolve("1em == 1px")
203
+ assert_equal "false", resolve("12 != 12")
204
+ end
205
+
206
+ def test_operation_precedence
207
+ assert_equal "false true", resolve("true and false false or true")
208
+ assert_equal "true", resolve("false and true or true and true")
209
+ assert_equal "true", resolve("1 == 2 or 3 == 3")
210
+ assert_equal "true", resolve("1 < 2 == 3 >= 3")
211
+ assert_equal "true", resolve("1 + 3 > 4 - 2")
212
+ assert_equal "11", resolve("1 + 2 * 3 + 4")
213
+ end
214
+
215
+ def test_functions
216
+ assert_equal "#80ff80", resolve("hsl(120, 100%, 75%)")
217
+ assert_equal "#81ff81", resolve("hsl(120, 100%, 75%) + #010001")
218
+ end
219
+
220
+ def test_operator_unit_conversion
221
+ assert_equal "1.1cm", resolve("1cm + 1mm")
222
+ assert_equal "true", resolve("2mm < 1cm")
223
+ assert_equal "true", resolve("10mm == 1cm")
224
+ assert_equal "true", resolve("1 == 1cm")
225
+ assert_equal "true", resolve("1.1cm == 11mm")
226
+ end
227
+
228
+ private
229
+
230
+ def resolve(str, opts = {}, environment = env)
231
+ munge_filename opts
232
+ eval(str, opts, environment).to_s
233
+ end
234
+
235
+ def eval(str, opts = {}, environment = env)
236
+ munge_filename opts
237
+ Sass::Script.parse(str, opts[:line] || 1,
238
+ opts[:offset] || 0, opts[:filename]).perform(environment)
239
+ end
240
+
241
+ def render(sass, options = {})
242
+ munge_filename options
243
+ Sass::Engine.new(sass, options).render
244
+ end
245
+
246
+ def env(hash = {})
247
+ env = Sass::Environment.new
248
+ hash.each {|k, v| env.set_var(k, v)}
249
+ env
250
+ end
251
+
252
+ def test_number_printing
253
+ assert_equal "1", eval("1")
254
+ assert_equal "1", eval("1.0")
255
+ assert_equal "1.121", eval("1.1214")
256
+ assert_equal "1.122", eval("1.1215")
257
+ assert_equal "Infinity", eval("1.0/0.0")
258
+ assert_equal "-Infinity", eval("-1.0/0.0")
259
+ assert_equal "NaN", eval("0.0/0.0")
260
+ end
261
+ end