Q:

CouchApp: List function with include_docs=true

I'm writing a simple CMS CouchApp as a pet project. I'm running CouchDB 1.2.0 on OS X 10.7.4 and using the Python CouchApp development tool.
Basically I wanna have pages as documents and a page would refer to another document that contains the shared layout of the site.
Example of a page document:
{
   "_id": "index",
   "_rev": "3-d5451ea54212ae6ec0d8d2d95c5f225d",
   "content": "<img src=\"/images/img.jpg\"/> <p>Lorem ipsum dolor sit amet.</p>",
   "layout": "layouts/default"
}

Example of a layout document:
{
   "_id": "layouts/default",
   "_rev": "1-d2fa96e15ab8768828b262d81265f3d2",
   "content": "<!DOCTYPE html> <html><head> <title>Foo</title> </head><body><div>{{content}}</div></body> </html>"
}

So basically to render a page I will need to fetch two documents. I would then render the page into the layout using Mustache.
I fiddled around with show functions for a while but couldn't figure out a way to get the layout document in the function. I then stumbled upon include_docs and I'm now trying to get this to work using a list function and a view. My map function is as follows:
function(doc) {
    if (doc.layout) {
        emit([doc._id, 1], doc);
        emit([doc._id, 0], {_id: doc.layout });
    }
};

When I navigate to the view itself in a browser giving the parameters include_docs=true&startkey=["index",0]&endkey=["index",1], it works just fine and is loading the layout documents.
However, the layout document doesn't get passed to list functions. Running this list function on the aforementioned view
function(head, req) {  
    var doc = null;
    var row = getRow();

    do
    {   
        if (!row.value.layout){
            doc = row.value;
        }
    } while (row = getRow())

    for (i in doc) {
        send(i);
    }
}

... with the same parameters renders:
_id

I did a bit of googling and noticed that there was a bug in CouchDB where linked documents didn't get passed onto the list function. As far as I can tell, this should be fixed already. Is this a case of regression or me being retarded?

A:

The value of the row is stored in row.value, but the doc for the row is in row.doc. :)

