This file contains hidden or 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
/* | |
* hookio/protocols/mustache | |
* Implements a mustache protocol for parsing mustache tags out of text | |
*/ | |
var hookIO = require('../../hookio').hookIO, | |
mu = require('../lib/mu/lib/mu'); | |
exports.start = function() { | |
// little test case |
This file contains hidden or 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
var http = require('http'), | |
sys = require('sys'); | |
http.createServer(function (request, response) { | |
response.writeHead(200, {'content-type': 'text/plain'}); | |
response.write("Hello"); | |
response.write(" "); | |
setTimeout(function () { |
This file contains hidden or 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
// Tested on Node version 0.1.32 and 0.1.33 | |
var http = require('http'), | |
sys = require('sys'); | |
http.createServer(function (request, response) { | |
response.writeHead(200, {'content-type': 'text/plain'}); | |
response.write("Hello"); | |
This file contains hidden or 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
function sanitize(string) { | |
return string.replace(/[&<>"]/g, escapeReplace); | |
} | |
function escapeReplace(char) { | |
switch (char) { | |
case '<': return '<'; | |
case '>': return '>'; | |
case '&': return '&'; | |
case '"': return '"'; |
This file contains hidden or 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
## Reader interface | |
event: 'data' | |
event: 'eof' | |
method: pause() | |
method: resume() | |
## Writer interface | |
method: write() | |
method: close() |
This file contains hidden or 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
var Posix = require('posix'), | |
Path = require('path'), | |
sys = require('sys'); | |
var Mu = exports; | |
// capture the base proto | |
var baseProto = ({}).__proto__; | |
Mu.cache = {}; | |
Mu.templatePaths = ['.', '']; |
This file contains hidden or 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
var sys = require('sys'); | |
var template ="<html>" + | |
"<body>" + | |
"<h1>{{ title }}</h1>" + | |
"{{# admin }}" + | |
"If admin {{ name }}" + | |
"{{/ admin }}" + | |
"</body>" + | |
"</html>"; |
This file contains hidden or 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
var p = Promise.join(p1, p2, p3) | |
p.addCallback(function (p1Res, p2Res, p3Res) { | |
// p1Res, p2Res, p3Res are arrays | |
}); | |
// or // | |
p.addCallback( | |
function (p1Res) { |
This file contains hidden or 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
var http = require('/http.js'); | |
var sys = require('/sys.js'); | |
var server = http.createServer(function (request, response) { | |
request.pause(); | |
request.addListener('body', function (chunk) { | |
sys.puts("Got body: " + chunk); | |
}); | |
request.addListener('complete', function () { |
This file contains hidden or 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
post('/', function () { | |
this.parseBody() | |
.addCallback(function (body) { | |
}); | |
}); | |
var promise = new node.Promise(); |