diff --git a/lib/hamlit/filters/css.rb b/lib/hamlit/filters/css.rb index 25caf3c4..3c6c4947 100644 --- a/lib/hamlit/filters/css.rb +++ b/lib/hamlit/filters/css.rb @@ -2,14 +2,42 @@ module Hamlit class Filters class Css < Base def compile(node) - text = compile_text(node.value[:text]) case @format when :xhtml - compile_xhtml('style', 'text/css', text) + compile_xhtml(node) else - compile_html('style', text) + compile_html(node) end end + + private + + def compile_text!(temple, node, prefix) + (node.value[:text].rstrip << "\n").each_line do |line| + if Haml::Util.contains_interpolation?(line) + temple << [:dynamic, Haml::Util.unescape_interpolation(prefix.dup << line)] + else + temple << [:static, prefix.dup << line] + end + temple << [:newline] + end + end + + def compile_html(node) + temple = [:multi] + temple << [:static, "'.freeze] + temple + end + + def compile_xhtml(node) + temple = [:multi] + temple << [:static, "".freeze] + temple + end end end end diff --git a/test/hamlit/filters/css_test.rb b/test/hamlit/filters/css_test.rb index 595abc1b..a3b1d67a 100644 --- a/test/hamlit/filters/css_test.rb +++ b/test/hamlit/filters/css_test.rb @@ -3,7 +3,6 @@ describe Hamlit::Filters do describe '#compile' do it 'renders css' do - skip assert_render(<<-HAML, <<-HTML) :css .foo { @@ -19,7 +18,6 @@ describe Hamlit::Filters do end it 'parses string interpolation' do - skip assert_render(<<-'HAML', <<-HTML) :css .foo {