1.0.4 • Published 7 years ago

jp-router v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

Simple Router Controller JS

demo básica de como manejar routers y controllers en javascript utilizando ES6.

##Install:

npm install jp-router --save

##Ejemplos:

Básico:

import Routes from 'jp-router';

var app = new Routes({location:window.location.pathname});

app.map('/', function(){
  console.log('index home');
});

Ejemplo controller:

import Routes from 'jp-router';
import UserController from './controllers/user';

var app = new Routes({location:window.location.pathname});

app.map('/user/:username/', UserController);

tambien acepta expresiones regulares:

app.map('/id/[0-9]+/', MyIdController);

Ejemplo de un blog:

app.map('/blog/:title/[0-9]+/', MyBlogController);

// in controller
class MyBlogController{
  constructor(title, id){
    this.title = title;
    this.id = id;
  }
}

work in progress..

1.0.4

7 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago