diff --git a/lib/jasmine/headless.rb b/lib/jasmine/headless.rb index 0a60efa..e145654 100644 --- a/lib/jasmine/headless.rb +++ b/lib/jasmine/headless.rb @@ -3,7 +3,7 @@ require 'pathname' module Jasmine module Headless - EXCLUDED_FORMATS = %w{less sass scss erb str} + EXCLUDED_FORMATS = %w{less sass scss str} autoload :CommandLine, 'jasmine/headless/command_line' @@ -23,6 +23,7 @@ module Jasmine autoload :FileChecker, 'jasmine/headless/file_checker' autoload :CoffeeTemplate, 'jasmine/headless/coffee_template' + autoload :CoffeeErbTemplate, 'jasmine/headless/coffee_erb_template' autoload :JSTemplate, 'jasmine/headless/js_template' autoload :JSTTemplate, 'jasmine/headless/jst_template' autoload :CSSTemplate, 'jasmine/headless/css_template' diff --git a/lib/jasmine/headless/coffee_erb_template.rb b/lib/jasmine/headless/coffee_erb_template.rb new file mode 100644 index 0000000..6fd1ab5 --- /dev/null +++ b/lib/jasmine/headless/coffee_erb_template.rb @@ -0,0 +1,20 @@ +require 'tilt/template' +require 'rainbow' + +module Jasmine::Headless + # This template flattens .coffee.erb files that may be present on + # the Rails asset pipeline. The file is rendered as CoffeeScript; + # erb template will not be rendered. + class CoffeeErbTemplate < Tilt::Template + + def prepare ; end + + def evaluate(scope, locals, &block) + if file[/coffee.erb$/] + Jasmine::Headless.warn("[%s] %s: %s" % [ "Erb File".color(:magenta), file.color(:yellow), "flatten template".color(:white) ]) + end + return '' + end + end +end + diff --git a/lib/jasmine/headless/files_list.rb b/lib/jasmine/headless/files_list.rb index 5e1acc9..05dc0bb 100644 --- a/lib/jasmine/headless/files_list.rb +++ b/lib/jasmine/headless/files_list.rb @@ -45,6 +45,7 @@ module Jasmine::Headless register_engine '.js', Jasmine::Headless::JSTemplate register_engine '.css', Jasmine::Headless::CSSTemplate register_engine '.jst', Jasmine::Headless::JSTTemplate + register_engine '.erb', Jasmine::Headless::CoffeeErbTemplate end end