Expressjs is returning json instead of html

I am developing a simple web app using kiwi templating engine and express. When I open my app in browser, template is correctly generated and everything but the result is JSON encoded. I tried setting res.type('html') but this only seems to change mime sent by application. I am not using any AJAX requests yet.

I have following code:

"use strict";

var express = require('express');
var path = require('path');
var publicDir = path.join(__dirname, 'public');

var app = express();

app.configure(function(){
    app.set('views', __dirname + '/view');
    app.engine('kiwi', require('kiwi').__express);
    app.set('view engine', 'kiwi');

    app.use(require('less-middleware')({ src: publicDir }));
    app.use(express.favicon());
    app.use(express.static(publicDir));
});
app.configure('development', function(){
    app.use(express.logger());
});


app.get('/', function(req, res){
    res.render('index', {title: 'kiwi'});
});

app.listen(process.env.PORT || 8080);

I use layout file like this (removed most of layout html for readability):

<div class="container">
    {{block content}}{{/block}}
</div>

This is index.kiwi file:

{{extend 'layout'}}
{{block content}}
<p>Hi ${title}</p>
{{/block}}

This is what I see in browser (sent with text/json mime):

"<div class=\"container\">\n\t\n<p>Hi kiwi</p>\n\n</div>"

How can I make it to send normal HTML?

UPDATE: OK, I managed to find another app similar to mine (using both express and kiwi) and only difference I found was library versions. So I downloaded express 3.0.0beta7 and it's working. Weird huh?

UPDATE2: The bug is between 3.0.0rc4 (html output) and 3.0.0rc5 (json output)

UPDATE3: I believe that only changes that could be relevant are commits 40be3ed05d and 9eb1da4568 both changing connect version or maybe 8edf358739

You can see the repo here: https://github.com/jtojnar/srs

FWIW (read your edits, just sharing ;): I recently checked out Kiwi templates and ran into the same issue.

My fix at the time was this:

  this.engine('kiwi', function(filename, options, callback) {
    kiwi.__express(filename, options, function(err, rendered) {
      if (! is_production && err)
        console.error(err);
      callback(err, rendered.toString());
    });
  });

The rendered argument wasn't a string, but an object. That confuses Express and makes (or rather: made) it return JSON instead. Didn't give me a whole lot of confidence in Kiwi, in the end I went for swig instead.