diff --git a/lib/haml/util.rb b/lib/haml/util.rb new file mode 100644 index 00000000..54de2755 --- /dev/null +++ b/lib/haml/util.rb @@ -0,0 +1,20 @@ +# This file contains various useful bits of code +# that are shared between Haml and Sass. + +class Hash # :nodoc: + # Same as Hash#merge!, + # but recursively merges sub-hashes and arrays + def rec_merge!(other) + other.each do |key, value| + myval = self[key] + if value.is_a?(Hash) && myval.is_a?(Hash) + myval.rec_merge!(value) + elsif value.is_a?(Array) && myval.is_a?(Array) + myval.concat(value) + else + self[key] = value + end + end + self + end +end diff --git a/test/sass/plugin_test.rb b/test/sass/plugin_test.rb index d9f11f78..0c7bc68b 100644 --- a/test/sass/plugin_test.rb +++ b/test/sass/plugin_test.rb @@ -23,7 +23,7 @@ class SassPluginTest < Test::Unit::TestCase end def teardown - #File.delete(*Dir[tempfile_loc('*')]) + File.delete(*Dir[tempfile_loc('*')]) end def test_templates_should_render_correctly diff --git a/test/sass/results/import.css b/test/sass/results/import.css new file mode 100644 index 00000000..bd285caf --- /dev/null +++ b/test/sass/results/import.css @@ -0,0 +1,27 @@ +imported { otherconst: hello; myconst: goodbye; } + +body { font: Arial; background: blue; } + +#page { width: 700px; height: 100; } +#page #header { height: 300px; } +#page #header h1 { font-size: 50px; color: blue; } + +#content.user.show #container.top #column.left { width: 100px; } +#content.user.show #container.top #column.right { width: 600px; } +#content.user.show #container.bottom { background: brown; } + +midrule { inthe: middle; } + +body { font: Arial; background: blue; } + +#page { width: 700px; height: 100; } +#page #header { height: 300px; } +#page #header h1 { font-size: 50px; color: blue; } + +#content.user.show #container.top #column.left { width: 100px; } +#content.user.show #container.top #column.right { width: 600px; } +#content.user.show #container.bottom { background: brown; } + +@import basic.css +@import ../results/complex.css +nonimported { myconst: hello; otherconst: goodbye; } diff --git a/test/sass/templates/bork2.sass b/test/sass/templates/bork2.sass new file mode 100644 index 00000000..462afb5a --- /dev/null +++ b/test/sass/templates/bork2.sass @@ -0,0 +1,2 @@ +bork + :bork: bork; diff --git a/test/sass/templates/import.sass b/test/sass/templates/import.sass new file mode 100644 index 00000000..d286c1d6 --- /dev/null +++ b/test/sass/templates/import.sass @@ -0,0 +1,8 @@ +!preconst = hello + +@import importee, basic, basic.css, ../results/complex.css + +nonimported + :myconst = !preconst + :otherconst = !postconst + diff --git a/test/sass/templates/importee.sass b/test/sass/templates/importee.sass new file mode 100644 index 00000000..631aa250 --- /dev/null +++ b/test/sass/templates/importee.sass @@ -0,0 +1,10 @@ +!postconst = goodbye + +imported + :otherconst = !preconst + :myconst = !postconst + +@import basic + +midrule + :inthe middle \ No newline at end of file