Skip to content
This repository

CoffeeFilter is a custom haml filter for rendering coffeescript.

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 coffee-filter.gemspec

For Haml < 4.0

Haml >= 4.0 includes built-in support for coffeescript.

What is coffee-filter?

Coffee-filter provides a custom haml filter allowing you to inline coffeescript in your haml templates. It was inspired by Ivan Nemytchenko's coffee-haml-filter but I wanted an installable gem and “coffeescript” as the filter name.



    alert 'here'


  <script type='text/javascript'>
      (function() {



Add the following to your Gemfile:

gem 'coffee-filter'


Using Ruby interpolation within the :coffeescript block will prevent Haml from caching the result of compilation. This means that your coffeescript block will be compiled by the coffeescript engine on runtime during every request, which is something you'll definitely want to avoid (since it's orders of magnitude slower).

In other words, using constructs similar to this:

  @server_time = #{}

will cost you around 100ms on each request. Either use the :javascript filter for this, or embed the dynamic content in some other way in the DOM.

Copyright © 2011 Paul Nicholson, released under the MIT license

Something went wrong with that request. Please try again.