Add less filter
This commit is contained in:
parent
c3aea3755a
commit
7bf8ce1f88
|
@ -26,11 +26,13 @@ Gem::Specification.new do |spec|
|
||||||
spec.add_development_dependency "erubis"
|
spec.add_development_dependency "erubis"
|
||||||
spec.add_development_dependency "faml"
|
spec.add_development_dependency "faml"
|
||||||
spec.add_development_dependency "haml"
|
spec.add_development_dependency "haml"
|
||||||
|
spec.add_development_dependency "less"
|
||||||
spec.add_development_dependency "pry"
|
spec.add_development_dependency "pry"
|
||||||
spec.add_development_dependency "rake"
|
spec.add_development_dependency "rake"
|
||||||
spec.add_development_dependency "rspec", ">= 3"
|
spec.add_development_dependency "rspec", ">= 3"
|
||||||
spec.add_development_dependency "sass"
|
spec.add_development_dependency "sass"
|
||||||
spec.add_development_dependency "slim"
|
spec.add_development_dependency "slim"
|
||||||
spec.add_development_dependency "tenjin"
|
spec.add_development_dependency "tenjin"
|
||||||
|
spec.add_development_dependency "therubyracer"
|
||||||
spec.add_development_dependency "unindent"
|
spec.add_development_dependency "unindent"
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,7 @@ require 'hamlit/concerns/registerable'
|
||||||
require 'hamlit/filters/css'
|
require 'hamlit/filters/css'
|
||||||
require 'hamlit/filters/escaped'
|
require 'hamlit/filters/escaped'
|
||||||
require 'hamlit/filters/javascript'
|
require 'hamlit/filters/javascript'
|
||||||
|
require 'hamlit/filters/less'
|
||||||
require 'hamlit/filters/plain'
|
require 'hamlit/filters/plain'
|
||||||
require 'hamlit/filters/preserve'
|
require 'hamlit/filters/preserve'
|
||||||
require 'hamlit/filters/ruby'
|
require 'hamlit/filters/ruby'
|
||||||
|
@ -22,6 +23,7 @@ module Hamlit
|
||||||
register :css, Filters::Css
|
register :css, Filters::Css
|
||||||
register :escaped, Filters::Escaped
|
register :escaped, Filters::Escaped
|
||||||
register :javascript, Filters::Javascript
|
register :javascript, Filters::Javascript
|
||||||
|
register :less, Filters::Less
|
||||||
register :plain, Filters::Plain
|
register :plain, Filters::Plain
|
||||||
register :preserve, Filters::Preserve
|
register :preserve, Filters::Preserve
|
||||||
register :ruby, Filters::Ruby
|
register :ruby, Filters::Ruby
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
require 'hamlit/filters/tilt'
|
||||||
|
|
||||||
|
module Hamlit
|
||||||
|
module Filters
|
||||||
|
class Less < Filters::Tilt
|
||||||
|
def compile(lines)
|
||||||
|
ast = [:html, :tag, 'style', [:html, :attrs]]
|
||||||
|
compile_with_tilt('less', lines.join("\n"), ast)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,22 @@
|
||||||
|
describe Hamlit::Filters::Less do
|
||||||
|
describe '#compile' do
|
||||||
|
it 'renders less filter' do
|
||||||
|
assert_render(<<-HAML, <<-HTML)
|
||||||
|
:less
|
||||||
|
.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