Permalink
Browse files

Merge branch 'master' of git://github.com/simonw/djangode

Conflicts:
	template/loader.js
	template_example.js
  • Loading branch information...
Anders Hellerup Madsen Anders Hellerup Madsen
Anders Hellerup Madsen authored and Anders Hellerup Madsen committed Feb 15, 2010
2 parents e889bcf + 7c0e8db commit aa7220849686bcb87f23ddd72019e8902ba04fa8
Showing with 10 additions and 6 deletions.
  1. +7 −4 djangode.js
  2. +3 −2 template_example.js
View
@@ -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('.');
@@ -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();
@@ -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;
View
@@ -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) {

0 comments on commit aa72208

Please sign in to comment.