Helper

Helper

The Helper class which can be used as utility function. Files from ${baseDir}/app/helper will be loaded to the prototype of Helper, then you can use all method on ctx.helper that is a instance of Helper.

Constructor

new Helper()

Source:

Methods

pathFor(name, params) → {String}

Generate URL path(withoud host) for route. Takes the route name and a map of named params.

Parameters:
Name Type Description
name String

Router Name

params Object

Other params

Source:
Example
```js
app.get('home', '/index.htm', 'home.index');
helper.pathFor('home', { by: 'recent', limit: 20 })
=> /index.htm?by=recent&limit=20
```

urlFor(name, params) → {String}

Generate full URL(with host) for route. Takes the route name and a map of named params.

Parameters:
Name Type Description
name String

Router name

params Object

Other params

Source:
Example
```js
app.get('home', '/index.htm', 'home.index');
helper.urlFor('home', { by: 'recent', limit: 20 })
=> http://127.0.0.1:7001/index.htm?by=recent&limit=20
```