An open API service indexing awesome lists of open source software.

https://github.com/llopez/js_router

Map rails routes helpers to javascripts functions
https://github.com/llopez/js_router

Last synced: 10 months ago
JSON representation

Map rails routes helpers to javascripts functions

Awesome Lists containing this project

README

          

Js Router
=========

[![Build Status](https://travis-ci.org/llopez/js_router.png?branch=master)](https://travis-ci.org/llopez/js_router)

### Introduction:

This is a Rails Engine for Rails3.

Map your rails url helpers into javascript.

### Installation:

Add to your Gemfile.

gem 'js_router', :git => 'git://github.com/llopez/js_router.git'

Then:

$ bundle

### Dependencies:

This engine uses the yui-compressor gem for compact javascripts.

gem install yui-compressor

### Setup:

In your application layout.

javascript_include_tag '/javascripts/routes', 'application'

### Now you can do:

If your config/routes.rb file looks like this:

YourApp::Application.routes.draw do
resources :posts
end

You can do:

jsRouter.postsPath() => /posts
jsRouter.newPostPath() => /posts/new
jsRouter.postPath(1) => /posts/1
jsRouter.editPostPath(1) => /posts/1/edit

Or with extra params:

postPath(1, {name: 'john', type: 'person'}) => /posts/1?name=john&type=person

### Testing

rake test

### TODO

Generate urls with domain.

### Author

llopez (Luis Lopez).