Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Ruby
branch: master

This branch is 1 commit ahead, 2 commits behind mokolabs:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
generators/javascripts
lib
test
LICENSE
README.markdown
Rakefile
init.rb

README.markdown

Javascripter

Javascripter is a Rails plugin that helps keep your javascript files organized.

Install

To install, just add Javascripter to your vendor/plugins directory:

script/plugin install git://github.com/mokolabs/javascripter.git

Usage

To use Javascripter, replace your javascript_include_tags with a single tag:

<head>
<title>the.rails.ist</title>
<%= javascripts %>
</head>

Once you do, your javascripts will be included automatically, using the conventions below.

<head>
<title>the.rails.ist</title>
<script src="/javascripts/application.js?1183566571" />
</head>

Organize your javascripts

Javascripter uses a simple set of conventions:

  • Javascript for your entire application should be stored in application.js
  • Javascript for specific controllers should be stored in controller.js
  • Javascript for specific actions should be stored in controller_action.js
  • Javascript for specific actions should be stored in controller/action.js (optional)

Follow these conventions and Javascripter will reward you with automagic goodness, loading javascripts for specific controllers or actions whenever they are active.

Support for :defaults

Need Prototype? Just use the :defaults parameter, like normal.

<%= javascripts :defaults %>

Include additional javascripts

Need to include extra javascript libraries? Use the :include parameter:

<%= javascripts :include => "lowpro" %>
<%= javascripts :include => ["lowpro", "lightbox"] %>

Generator

Javascripter also includes a generator that will create a default application.js script and separate javascript files for each controller in your application.

To use the generator, run this command in your terminal:

script/generate javascripts

If you add a new controller, just run the generator again and a new javascript for the controller will be created. (Existing javascripts will be ignored.)

Credits

Special thanks to Lachie Cox and the rest of my RORO Sydney comrades who asked for this plugin.

Feedback

Comments and patches welcome at http://github.com/mokolabs/javascripter/.

Something went wrong with that request. Please try again.