function(action){

        var url;
        var error;

        // Iterate over the routes, looking for a match.
        var routes = this.getRoutes();
        for (var i = 0; url === undefined && i < routes.length; i++){

            try {

                // Simplify access.
                var route = routes[i];

                // Check the controller + method. If we find one, figure out the URL to return.
                if (action == route.controller + '.' + route.method){

                    var params = [];

                    // If there are parameters, bind them.
                    if (arguments.length > 1) {

                        // Turn them into a proper array.
                        params = Array.prototype.slice.apply(arguments);

                        // And drop the first entry (which was the action itself).
                        params = params.slice(1);
                    }

                    // We always call bind, even with an empty array, to see if we generate an error.
                    url = this.bindUrl(route.path, params);
                }
            }

            catch(e) {

                // Store the error in case we need to rethrow it.
                error = e;
            }

        }

        // If we found a match, return it.
        if (url !== undefined) {
            return url;
        }

        // Otherwise, throw an exception.
        else {

            // If we captured an earlier error, reuse that (since it implies we found a match but couldn't bind it).
            if (error !== undefined) {
                throw error;
            }

            else {
                throw new Error("No matching action was found.");
            }
        }
    }
function(action){

        var url;
        var error;

        
        var routes = this.getRoutes();
        for (var i = 0; url === undefined && i < routes.length; i++){

            try {

                
                var route = routes[i];

                
                if (action == route.controller + '.' + route.method){

                    var params = [];

                    
                    if (arguments.length > 1) {

                        
                        params = Array.prototype.slice.apply(arguments);

                        
                        params = params.slice(1);
                    }

                    
                    url = this.bindUrl(route.path, params);
                }
            }

            catch(e) {

                
                error = e;
            }

        }

        
        if (url !== undefined) {
            return url;
        }

        
        else {

            
            if (error !== undefined) {
                throw error;
            }

            else {
                throw new Error("No matching action was found.");
            }
        }
    }
function ( action ) { var url ; var error ; // Iterate over the routes, looking for a match. var routes = this . getRoutes ( ) ; for ( var i = 0 ; url === undefined && i < routes . length ; i ++ ) { try { // Simplify access. var route = routes [ i ] ; // Check the controller + method. If we find one, figure out the URL to return. if ( action == route . controller + '.' + route . method ) { var params = [ ] ; // If there are parameters, bind them. if ( arguments . length > 1 ) { // Turn them into a proper array. params = Array . prototype . slice . apply ( arguments ) ; // And drop the first entry (which was the action itself). params = params . slice ( 1 ) ; } // We always call bind, even with an empty array, to see if we generate an error. url = this . bindUrl ( route . path , params ) ; } } catch ( e ) { // Store the error in case we need to rethrow it. error = e ; } } // If we found a match, return it. if ( url !== undefined ) { return url ; } // Otherwise, throw an exception. else { // If we captured an earlier error, reuse that (since it implies we found a match but couldn't bind it). if ( error !== undefined ) { throw error ; } else { throw new Error ( "No matching action was found." ) ; } } }
Given an action and an optional set of parameters, returns the URL to be used.
@param {string} action The URL to bind.
@return {string} A function which accepts a variable number of parameters and binds those to places in the URL.
Given an action and an optional set of parameters returns the URL to be used .