Steve Klabnik changelog.com/posts

Coffeebeans: extra CoffeeScript helpers for Rails 3.1

If you didn’t catch DHH’s keynote at Railsconf, he made a strong assertion: CoffeeScript is here to stay. You don’t have to use it if you don’t want to, but by default, Rails 3.1 will generate CoffeeScript for all your JavaScript needs.

With that said, Mark Bates thinks they didn’t go far enough. When he pitched Rails core about adding some more helpers, they said they wanted to work on the implementation, but they liked the idea. So Mark put together a gem to hold you off until this makes its way into core!

So what’d they leave out? Well, for one thing, inline CoffeeScript:

<%= coffee_script_tag do %>
  alert 'coffee script is awesome!'
<% end %>

This generates

 // a script tag
  (function() {
    alert('coffee script is awesome!');
  }).call(this);
// closing script tag

via the CoffeeScript compiler. It also lets you more closely integrate CoffeeScript into your existing scripts, and some other small things, too.

You can get it through Rubygems, it’s just a

gem install coffeebeans

away!

[README] [GitHub]


Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00