1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Implement css filter

This commit is contained in:
Takashi Kokubun 2015-03-16 19:35:59 +09:00
parent 57eed97f28
commit f482296c24
3 changed files with 29 additions and 0 deletions

View file

@ -1,5 +1,6 @@
require 'temple/html/filter'
require 'hamlit/concerns/registerable'
require 'hamlit/filters/css'
require 'hamlit/filters/javascript'
module Hamlit
@ -7,6 +8,7 @@ module Hamlit
extend Concerns::Registerable
register :javascript, Filters::Javascript
register :css, Filters::Css
def on_haml_filter(name, exp)
compiler = FilterCompiler.find(name)

View file

@ -0,0 +1,9 @@
module Hamlit
module Filters
class Css
def compile(exp)
[:html, :tag, 'style', [:html, :attrs], exp]
end
end
end
end

View file

@ -0,0 +1,18 @@
describe Hamlit::Filters::Css do
describe '#compile' do
it 'renders css' do
assert_render(<<-HAML, <<-HTML)
:css
.foo {
width: 100px;
}
HAML
<style>
.foo {
width: 100px;
}
</style>
HTML
end
end
end