Created
July 11, 2011 07:48
-
-
Save 3rd-Eden/1075441 to your computer and use it in GitHub Desktop.
Debug statement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 : ''); | |
}; |
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 {{
)
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.
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
And than in our builder.js we could completely remove the statement with a simple regexp
{{[^{{]+?}}\r?
like that