Giter Site home page Giter Site logo

fabiokr / javascripter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mokolabs/javascripter

1.0 2.0 1.0 79 KB

Organize your javascript

Home Page: http://the.railsi.st/2007/08/22/javascripter-organize-your-javascript

License: MIT License

JavaScript 0.01% Ruby 100.00%

javascripter's Introduction

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/.

javascripter's People

Contributors

mokolabs avatar

Stargazers

Fabio Kreusch avatar

Watchers

Fabio Kreusch avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.