Coder Social home page Coder Social logo

ligne_route's Introduction

Utilitario generar url relativas (Enfocado a AJAX)

Ventajas:

  • No tienes que preocuparte por la entrada de caracteres no deseados.
  • Muy sencillo de utilizar.
  • No tiene dependencias.
  • Funciona tanto en local como en internet con http y https.

Uso básico

Se debe especificar controlador y acción, en caso de contener parámetros se pueden agregar.

Ruta normal
let route = new Route('foo','bar');

Ruta con parametros

let route = new Route('foo','bar',1);

O

let route = new Route('foo','bar','any');

Array de parámetros

let route = new Route('foo','bar',['products',1,'any']);

Para obtener la ruta solo debe invocarse el método route

let route = new Route('foo','bar');
console.log( route.route );
http://localhost/mypath/foo/bar

Otras opciones

También puedes especificar si quieres que se incluya el pathname o no, o uno personalizado, por defecto se incluye..

let route = new Route('foo','bar',1, false);
console.log(route.route);

http://localhost/mypath/foo/bar

También si no quiero indicar ningún parámetro puedo pasar null como segundo parámetro

let route = new Route('foo','bar',null, false);
console.log(route.route);

Excluyendo el patch

let route = new Route('foo','bar',null, true);
console.log(route.route);
http://localhost/foo/bar

Personalizado

let route = new Route('foo','bar',null,'custom_path');
console.log(route.route);
http://localhost/custom_path/foo/bar

ligne_route's People

Contributors

itsalb3rt avatar

Stargazers

 avatar  avatar

Watchers

 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.