jQuery Templates for the Rails asset pipeline.
Ruby
Switch branches/tags
Nothing to show
Pull request Compare This branch is 1 commit ahead, 19 commits behind jimmycuadra:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
vendor/assets/javascripts
.gitignore
.rspec
Gemfile
LICENSE
README.textile
Rakefile
jquery-tmpl-rails.gemspec

README.textile

jquery-tmpl-rails

This gem adds the jQuery Templates plugin and a corresponding Sprockets engine to the asset pipeline in Rails => 3.1 applications.

Installation

Add it to your gemfile:

gem "jquery-tmpl-rails"

Update your bundle:

bundle install

Usage

Place individual jQuery templates in their own files with the .tmpl extension:

<!-- app/assets/javascripts/tmpl/author.tmpl -->
<div class="author">${name}</div>

In your manifest file, require the plugin followed by your individual templates. The templates are compiled and named with their Sprockets logical path:

//= require jquery-tmpl
//= require tmpl/author

$.tmpl("tmpl/author", { name: "Jimmy" }).appendTo("#author");

Happy templating!

Acknowledgements

The .tmpl Sprockets engine is based on the sprockets-jquery-tmpl gem. If you want a similar mechanism for use outside of Rails, take a look at this project.