Add scss filter
This commit is contained in:
parent
d2ed383d86
commit
c3aea3755a
|
@ -7,6 +7,7 @@ require 'hamlit/filters/plain'
|
|||
require 'hamlit/filters/preserve'
|
||||
require 'hamlit/filters/ruby'
|
||||
require 'hamlit/filters/sass'
|
||||
require 'hamlit/filters/scss'
|
||||
|
||||
module Hamlit
|
||||
module Compilers
|
||||
|
@ -25,6 +26,7 @@ module Hamlit
|
|||
register :preserve, Filters::Preserve
|
||||
register :ruby, Filters::Ruby
|
||||
register :sass, Filters::Sass
|
||||
register :scss, Filters::Scss
|
||||
end
|
||||
|
||||
def on_haml_filter(name, lines)
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
require 'hamlit/filters/tilt'
|
||||
|
||||
module Hamlit
|
||||
module Filters
|
||||
class Scss < Filters::Tilt
|
||||
def compile(lines)
|
||||
ast = [:html, :tag, 'style', [:html, :attrs]]
|
||||
compile_with_tilt('scss', lines.join("\n"), ast)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,21 @@
|
|||
describe Hamlit::Filters::Scss do
|
||||
describe '#compile' do
|
||||
it 'renders scss filter' do
|
||||
assert_render(<<-HAML, <<-HTML)
|
||||
:scss
|
||||
.users_controller {
|
||||
.show_action {
|
||||
margin: 10px;
|
||||
padding: 20px;
|
||||
}
|
||||
}
|
||||
HAML
|
||||
<style>
|
||||
.users_controller .show_action {
|
||||
margin: 10px;
|
||||
padding: 20px; }
|
||||
</style>
|
||||
HTML
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue