Jquery Tmpl Rails

screenshot of Jquery Tmpl Rails
rails

jQuery Templates for the Rails asset pipeline.

Overview

The jquery-tmpl-rails gem adds the jQuery Templates plugin and a corresponding Sprockets engine to the asset pipeline in Rails >= 3.1 applications.

Features

  • Adds the jQuery Templates plugin to Rails applications
  • Integrates the jQuery Templates plugin with Sprockets asset pipeline
  • Templates are recognized by Sprockets with the .tmpl extension

Usage

  1. Place your jQuery templates anywhere in the Sprockets load path.
  2. Require the jQuery Templates plugin followed by your templates in your application's JavaScript manifest file:
//= require jquery-tmpl
//= require_tree ./templates
  1. The templates will be compiled and named with their Sprockets logical path.

Configuration

If all of your templates have a common prefix that you prefer not to be included in the template's name, you can set this option in config/application.rb:

config.jquery_templates.prefix_namespace = 'common_prefix'

This configuration would change the example above to:

//= require jquery-tmpl
//= require_tree ./common_prefix

The prefix can also be a regular expression to customize the template name based on the file's directory structure.

Summary

The jquery-tmpl-rails gem is a useful tool for integrating the jQuery Templates plugin with the asset pipeline in Rails applications. It provides an easy way to include jQuery templates and utilize them in your JavaScript code. With simple installation and configuration steps, the gem enhances the development experience for Rails developers using the jQuery Templates plugin.

rails
Ruby on Rails

Ruby on Rails, often referred to as Rails, is an open-source web application framework written in Ruby. Known for its convention over configuration and don't repeat yourself (DRY) principles, Rails simplifies and accelerates the development of database-backed web applications.