johnbintz/jasmine-headless-webkit — pull request #111 by rossta (2012-01-22 23:47:43+00:00)
Title: Ability to register custom template engines...

...via Jasmine::Headless.register_engine hook

In response to [issue #102](https://github.com/johnbintz/jasmine-headless-webkit/issues/102), I added the ability to register custom template engines not currently supported by default in JHW. The hook may be registered by placing ruby code in #{spec_dir}/helpers/spec_helper.rb. (Perhaps the location of this file can be configurable.)

For example, I am using the following to compile Handlebars assets via the `handlebar_assets` gem for JHW in my current project:

```ruby
# spec/javascripts/helpers/spec_helper.rb

require 'sprockets'
require 'handlebars_assets'

module Jasmine::Headless
class HandlebarsTemplate < HandlebarsAssets::TiltHandlebars
include Jasmine::Headless::FileChecker
def evaluate(*args)
if bad_format?(file)
alert_bad_format(file)
return ''
end
%{}
end
end
end

Jasmine::Headless.register_engine '.hbs', Jasmine::Headless::HandlebarsTemplate
```