Version: v0.7.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 Route Params)

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

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

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

// URL: /post/book-review

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

Validation

It will be validated per the given $ruleset. (See Input Validation)

If it does not pass validation, a default value will be returned for its type.

// Route: /user/{userId}

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

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

See Also

See Also