nl_tokens: Binds the given parameters into the given URL . Used ala Router . reverse () in Play!
pl_tokens: 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 <mask> ; }