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:
parent
57eed97f28
commit
f482296c24
3 changed files with 29 additions and 0 deletions
|
@ -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)
|
||||
|
|
9
lib/hamlit/filters/css.rb
Normal file
9
lib/hamlit/filters/css.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
module Hamlit
|
||||
module Filters
|
||||
class Css
|
||||
def compile(exp)
|
||||
[:html, :tag, 'style', [:html, :attrs], exp]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
18
spec/hamlit/filters/css_spec.rb
Normal file
18
spec/hamlit/filters/css_spec.rb
Normal 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
|
Loading…
Add table
Reference in a new issue