lib/Hecate.js
function(url, params){

        // If the parameters weren't in the form of an array, fix that.
        if (!(params instanceof Array)){
            params = [params];
        }

        // Compile the regex used for matching named URL parameters.
        var regex = /:\w+/i;

        // If they provided parameters, try to use them.
        if (params.length > 0) {

            // Keep going so long as there are parameters to attempt to bind.
            for (var i = 0; i < params.length; i++) {

                // Grab the value.
                var val = params[i];

                // If it's an object, we treat it slightly differently.
                if (typeof val == "object") {
                    url = this.bindObject(url, val);
                }

                // Otherwise, replace the next variable in the string with the value.
                else {
                    url = url.replace(regex, val);
                }
            }

        }

        // If, after all processing, the URL is still missing bits, throw an exception.
        // We do this afterwards to avoid having to guess whether objects are going to populate our string properly.
        if (url.indexOf(':') >= 0){

            // Tell them which variable they missed.
            throw new Error('Insufficient parameters passed. Unable to bind: ' + url.match(regex)[0]);
        }

        return url;
    }
function(url, params){

        // If the parameters weren't in the form of an array, fix that.
        if (!(params instanceof Array)){
            params = [params];
        }

        // Compile the regex used for matching named URL parameters.
        var regex = /:\w+/i;

        // If they provided parameters, try to use them.
        if (params.length > 0) {

            // Keep going so long as there are parameters to attempt to bind.
            for (var i = 0; i < params.length; i++) {

                // Grab the value.
                var val = params[i];

                // If it's an object, we treat it slightly differently.
                if (typeof val == "object") {
                    url = this.bindObject(url, val);
                }

                // Otherwise, replace the next variable in the string with the value.
                else {
                    url = url.replace(regex, val);
                }
            }

        }

        // If, after all processing, the URL is still missing bits, throw an exception.
        // We do this afterwards to avoid having to guess whether objects are going to populate our string properly.
        if (url.indexOf(':') >= 0){

            // Tell them which variable they missed.
            throw new Error('Insufficient parameters passed. Unable to bind: ' + url.match(regex)[0]);
        }

        return url;
    }
function ( url , params ) { // If the parameters weren't in the form of an array, fix that. if ( ! ( params instanceof Array ) ) { params = [ params ] ; } // Compile the regex used for matching named URL parameters. var regex = / :\w+ / i ; // If they provided parameters, try to use them. if ( params . length > 0 ) { // Keep going so long as there are parameters to attempt to bind. for ( var i = 0 ; i < params . length ; i ++ ) { // Grab the value. var val = params [ i ] ; // If it's an object, we treat it slightly differently. if ( typeof val == "object" ) { url = this . bindObject ( url , val ) ; } // Otherwise, replace the next variable in the string with the value. else { url = url . replace ( regex , val ) ; } } } // If, after all processing, the URL is still missing bits, throw an exception. // We do this afterwards to avoid having to guess whether objects are going to populate our string properly. if ( url . indexOf ( ':' ) >= 0 ) { // Tell them which variable they missed. throw new Error ( 'Insufficient parameters passed. Unable to bind: ' + url . match ( regex ) [ 0 ] ) ; } return url ; }
Binds the given parameters into the given URL.
Used ala Router.reverse() in Play!
@param {string} url The URL pattern to bind against.
@param {mixed} params A varargs collection of parameters to bind.
Binds the given parameters into the given URL . Used ala Router . reverse () in Play!