Skip to content

Instantly share code, notes, and snippets.

@3rd-Eden
Created July 11, 2011 07:48
Show Gist options
  • Save 3rd-Eden/1075441 to your computer and use it in GitHub Desktop.
Save 3rd-Eden/1075441 to your computer and use it in GitHub Desktop.
Debug statement
/**
* Manages connections to hosts.
*
* @param {String} uri
* @Param {Boolean} force creation of new socket (defaults to false)
* @api public
*/
io.connect = function (host, details) {
var uri = io.util.parseUri(host)
, uuri
, socket;
if ('undefined' != typeof document) {
uri.protocol = uri.protocol || document.location.protocol.slice(0, -1);
uri.host = uri.host || document.domain;
uri.port = uri.port || document.location.port;
}
{{
// confirm that the uri is correctly parsed
io.log.debug('uri', uri);
}}
uuri = io.util.uniqueUri(uri);
var options = {
host: uri.host
, secure: uri.protocol == 'https'
, port: uri.port || 80
};
io.util.merge(options, details);
if (options['force new connection'] || !io.sockets[uuri]) {
socket = new io.Socket(options);
}
if (!options['force new connection'] && socket) {
io.sockets[uuri] = socket;
}
socket = socket || io.sockets[uuri];
// if path is different from '' or /
return socket.of(uri.path.length > 1 ? uri.path : '');
};
@3rd-Eden
Copy link
Author

And than in our builder.js we could completely remove the statement with a simple regexp {{[^{{]+?}}\r? like that

@dvv
Copy link

dvv commented Jul 11, 2011

better we can reuse underscore's tiny templating (and even express res.render, though it would be very tough dep) and use <% statements %> and <%= expression %> (or whatever instead of <%, including mustache-style {{)

@3rd-Eden
Copy link
Author

The thing is.. writing {{ is valid javascript. Doing <$ will throw an error.

Unless you something like:

'<%'
    io.log.debug('uri', uri);
'%>'

Which requires much more typing to make it readable for javascript engines.

@dvv
Copy link

dvv commented Jul 11, 2011

i understand that (or whatever instead of <%, including mustache-style {{). the point was to possibly make internal static server smarter to support templating

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment