Version: v0.8.0 - Beta.  We welcome contributors & feedback.

Input.route

Input.route($paramName, $ruleset='id') -> any

Description

Get the value of a URL route parameter.

Routes are defined in config/app.jcon. (See Custom Routes)

// config/app.jcon
//-----------------------------------

routes: {
    /post/{postTitle}: post.tht
}

// code/pages/post.tht
//-----------------------------------

// URL: /post/book-review

Input.route('postTitle')
//= 'book-review'

Validation

Route params are validated per the given $ruleset. (See Input Validation)

If it does not pass validation, a falsey default value will be returned for its type (e.g. zero or an empty string).

// Route: /user/{userId}

// URL: /user/314
Input.route('userId', 'i')
//= 314

// URL: /user/abcd
Input.route('userId', 'i')
//= 0  (invalid)

See Also

See Also