Read URL parameters in a route
Wrap a segment of the URL in curly braces and Total.js exposes its value in $.params. A route can contain as many parameters as you need.
exports.install = function() {
ROUTE('GET /users/{id}/', show_user);
ROUTE('GET /users/{id}/posts/{post}/', show_post);
};
function show_user($) {
$.json({ id: $.params.id });
}
function show_post($) {
$.json({ id: $.params.id, post: $.params.post });
}$.json() sends the value as JSON. Parameters are always strings; validate or convert them yourself, or declare their types in an action (see the actions recipe).