sails-hook-route
v0.0.8
Published
Bind route function to res.locals to get the URL of a route by it's name property and replace the named parameters by their values automatically
Downloads
4
Maintainers
Readme
sails-hook-route
Laravel-like route function for Sailsjs.
Installation
$ npm install sails-hook-route
How to use
- In your config/routes.js file, add a name property for a route you want to be named :
// Some routes
'GET /foo/:id': {
name: 'foo',
controller: 'SomeController',
action: 'bar'
// Some routes
}
- In your template file :
<a href="<%= route('foo', 5) %>">Foo</a>
and it will produce
<a href="/foo/5">Foo</a>