walrus-rails

JST style templates with walrus.js via Sprockets

Summary

Write files named app/assets/javascripts/templates/tmpl.js.wal and use them client-side like this:

window.walrus_templates["templates/tmpl"](obj)

Installation

Add walrus-rails to your Gemfile

gem "walrus-rails"

This will register a new template engine in Sprockets to handle .wal files

Make sure to include your templates in your main application.js, for example:

//= require_tree ./templates

You'll also need walrus.js

That's it!

Configuration

You can change the namespace walrus_templates if you like:

# In some initialization code
Sprockets::WalrusTemplate.namespace = 'this.JST'