Skip to content

cubus/jquery-tmpl-rails

 
 

Repository files navigation

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.

Packages

No packages published

Languages

  • Ruby 100.0%