diff --git a/hamlit.gemspec b/hamlit.gemspec
index dde2b342..b87710aa 100644
--- a/hamlit.gemspec
+++ b/hamlit.gemspec
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "tilt"
spec.add_development_dependency "benchmark-ips"
spec.add_development_dependency "bundler"
+ spec.add_development_dependency "coffee-script"
spec.add_development_dependency "erubis"
spec.add_development_dependency "faml"
spec.add_development_dependency "haml"
diff --git a/lib/hamlit/compilers/filter.rb b/lib/hamlit/compilers/filter.rb
index 9dd3cbfc..8a5ba256 100644
--- a/lib/hamlit/compilers/filter.rb
+++ b/lib/hamlit/compilers/filter.rb
@@ -1,5 +1,6 @@
require 'hamlit/concerns/included'
require 'hamlit/concerns/registerable'
+require 'hamlit/filters/coffee'
require 'hamlit/filters/css'
require 'hamlit/filters/erb'
require 'hamlit/filters/escaped'
@@ -22,17 +23,19 @@ module Hamlit
define_options :format
- register :css, Filters::Css
- register :erb, Filters::Erb
- register :escaped, Filters::Escaped
- register :javascript, Filters::Javascript
- register :less, Filters::Less
- register :markdown, Filters::Markdown
- register :plain, Filters::Plain
- register :preserve, Filters::Preserve
- register :ruby, Filters::Ruby
- register :sass, Filters::Sass
- register :scss, Filters::Scss
+ register :coffee, Filters::Coffee
+ register :coffeescript, Filters::Coffee
+ register :css, Filters::Css
+ register :erb, Filters::Erb
+ register :escaped, Filters::Escaped
+ register :javascript, Filters::Javascript
+ register :less, Filters::Less
+ register :markdown, Filters::Markdown
+ register :plain, Filters::Plain
+ register :preserve, Filters::Preserve
+ register :ruby, Filters::Ruby
+ register :sass, Filters::Sass
+ register :scss, Filters::Scss
end
def on_haml_filter(name, lines)
diff --git a/lib/hamlit/filters/coffee.rb b/lib/hamlit/filters/coffee.rb
new file mode 100644
index 00000000..a24676d4
--- /dev/null
+++ b/lib/hamlit/filters/coffee.rb
@@ -0,0 +1,12 @@
+require 'hamlit/filters/tilt'
+
+module Hamlit
+ module Filters
+ class Coffee < Filters::Tilt
+ def compile(lines)
+ ast = [:html, :tag, 'script', [:html, :attrs]]
+ compile_with_tilt('coffee', lines.join("\n"), ast)
+ end
+ end
+ end
+end
diff --git a/spec/hamlit/filters/coffee_spec.rb b/spec/hamlit/filters/coffee_spec.rb
new file mode 100644
index 00000000..84e03491
--- /dev/null
+++ b/spec/hamlit/filters/coffee_spec.rb
@@ -0,0 +1,41 @@
+describe Hamlit::Filters::Coffee do
+ describe '#compile' do
+ it 'renders coffee filter' do
+ assert_render(<<-HAML, <<-HTML)
+ :coffee
+ foo = ->
+ alert('hello')
+ HAML
+
+ HTML
+ end
+
+ it 'renders coffeescript filter' do
+ assert_render(<<-HAML, <<-HTML)
+ :coffee
+ foo = ->
+ alert('hello')
+ HAML
+
+ HTML
+ end
+ end
+end