# Using clientside-haml-js with Sprockets and Rails 3.1/3.2 ## About Inspired by [haml-sprockets]. Use [clientside-haml-js] to render your haml templates with javascript/coffeescript and haml. ## How to use it? The gem includes [clientside-haml-js], [JSON-js] for IE, [underscore] and [underscore.string]. You would not have to download it separately. To use this gem, you need to do the following: In the `Gemfile`, add the following line. gem "cshaml-sprockets" In `app/assets/javascripts/application.js` add the following line before `//= require_tree .` //=require json2 //=require underscore //=require underscore.string //=require haml Now, you can create cshamljs files under `app/assets/javascripts/templates` folder. You can create the templates folder, if it does not already exist. // code for app/assets/javascripts/templates/hello.jst.cshamljs %h1 Hello HAML Or to use CoffeeScript in haml templates name the file // code for app/assets/javascripts/templates/hello.jst.cshamlcoffee %h1= @model.title You can now access the template anywhere in your javascript or coffeescript code. JST["templates/hello"](model: model) This should give you back the string `"