Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/simonw/djangode
Browse files Browse the repository at this point in the history
Conflicts:
	template/loader.js
	template_example.js
  • Loading branch information
Anders Hellerup Madsen authored and Anders Hellerup Madsen committed Feb 15, 2010
2 parents e889bcf + 7c0e8db commit aa72208
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 7 additions & 4 deletions djangode.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var http = require('http'),
sys = require('sys'),
posix = require('posix')
url = require('url');
posix = require('posix'),
url = require('url');

function extname(path) {
var index = path.lastIndexOf('.');
Expand All @@ -26,7 +26,10 @@ exports.serveFile = function(req, res, filename) {
body = data;
headers = [
['Content-Type', content_type],
['Content-Length', encoding === 'utf8' ? encodeURIComponent(body).replace(/%../g, 'x').length : body.length]
['Content-Length', (encoding === 'utf8')
? encodeURIComponent(body).replace(/%../g, 'x').length
: body.length
]
];
sys.puts("static file " + filename + " loaded");
callback();
Expand Down Expand Up @@ -55,7 +58,7 @@ function respond(res, body, content_type, status) {
res.sendHeader(status || 200, {
'Content-Type': content_type + '; charset=utf-8'
});
res.sendBody(body);
res.sendBody(body, 'utf8');
res.finish();
}
exports.respond = respond;
Expand Down
5 changes: 3 additions & 2 deletions template_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ var app = dj.makeApp([
['^/(template-demo/.*)$', dj.serveFile],

['^/template$', function (req, res) {
var html = template_system.load('template.html').render(test_context);
dj.respond(res, html);
template_system.load('template.html', function(t) {
dj.respond(res, t.render(test_context));
});
}],

['^/text$', function (req, res) {
Expand Down

0 comments on commit aa72208

Please sign in to comment.