Skip to content
This repository was archived by the owner on Nov 16, 2017. It is now read-only.
/ jquery_tag Public archive

Simple helper for togglin' jQuery from Google's CDN/local app seamlessly on your Rails/Sinatra application.

Notifications You must be signed in to change notification settings

lucasmazza/jquery_tag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jquery_tag

Build Status

A Helper gem for both Rails and Sinatra for toggling between a local jquery.js file or the hosted script on Google's CDN based on your application environment, avoiding network dependency during development and bandwidth usage when your application goes live. It also supports the same behavior for a loading the jQuery UI script.

To know more about the benefits of using a CDN for your common Javascript frameworks, check this Chris Coyier post at CSS-Tricks.

Installation

If you're using Bundler, just add the jquery_tag to your Gemfile and run bundle install. If not, gem install jquery_tag and require 'jquery_tag' inside your application code.

To download the latest jQuery script to your application just run jquery_tag command inside your Terminal and the script will be downloaded to public/javascripts/jquery.js. You can check the available options running it with the -h flag.

Usage

Inside your views, you can just call the jquery_tag method.

<%= jquery_tag %>

It accepts a some configuration options by using the following symbols:

:version          # Overrides the script version on the CDN URL. Defaults do '1.7.0'
:file             # Path for the local script. Defaults do 'jquery.js'
:ui               # Loads jQuery UI. Accepts a true value for loading a 'jquery-ui.js' file or a String for the local path.

Any other arguments will be passed along to the javascript_include_tag helper, if inside a Rails application. The Sinatra Helper currently ignores any extra option.

Sinatra

To use the jquery_tag on your Sinatra applications, just include the JqueryTag::SinatraHelper on your application

require 'jquery_tag' # if your not using Bundler.

class Application < Sinatra::Base
  helpers do
    include JqueryTag::SinatraHelper
  end
end

Just call the jquery_tag helper inside your views or layouts, as in the example above. Your local scripts should be located inside a ./public/javascripts/ folder (or whatever the Sinatra public path is configured on your application).

About

Simple helper for togglin' jQuery from Google's CDN/local app seamlessly on your Rails/Sinatra application.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages