Skip to content
CoffeeScript in your views
Ruby JavaScript CoffeeScript
Find file
Latest commit b9abf91 Jun 4, 2013 @yury Cut spaces
Failed to load latest commit information.
lib Fix specs Jun 4, 2013
spec Fix specs Jun 3, 2013
.gitignore Add tests with dummy app Oct 3, 2011
Gemfile Fix xss, based on… Jan 19, 2013
LICENSE initial implementation Jul 9, 2011
Rakefile Rake tasks for gems Jan 19, 2013
coffee-views.gemspec Cut spaces Jun 4, 2013


Inspired by coffeebeans but with fixes:

  1. Doesn't compile coffeescript everytime in production
  2. Smart replacements for <%=%>

Use #to_json in safe mode

<%=  x %> # replaced with `<%== (x).to_json %>`

Use raw mode in raw mode

<%== x %> # replaced with `<%== x %>`


In your Gemfile:

gem "coffee-views"


This library depends on the coffee-script gem


# in
$("#item").html <%= render "user/card" %>

Note: There is no need to call j or escape_javascipt helpers.

Coffee Script string interpolation like syntax (#{=} for safe and #{==} for raw):

# in
alert "hello #{=}"

You can use coffeeview: embedded engine in slim

h1 Say Hi
  alert <%= @some_view_string %>
Something went wrong with that request. Please try again.