function (doc, req) {
    // !json templates.page

    var mustache = require("vendor/couchapp/lib/mustache");

    var path;
    if (typeof(req.path[5]) === 'undefined') {
        path = "../"
    } else {
        path = "../../"
    }

    data = {
        attachment_path: path,
        version: 1.0,
        errormessage: "hey",
        cipherdata: typeof(req.path[5])
    }
    return mustache.to_html(this.templates.page, data);
}

@@ -121,52 +121,77 @@
 path
-;%0A    if (typeof(req.path%5B5%5D
+, cipherdata, errormessage;%0A%0A    if (req.raw_path.substr(-4
 ) ==
-=
  '
-undefined
+main
 ') %7B
@@ -207,24 +207,25 @@
 path = %22../%22
+;
 %0A    %7D else 
@@ -249,16 +249,113 @@
 %22../../%22
+;%0A    %7D%0A%0A    if (doc) %7B%0A        cipherdata = doc.content;%0A    %7D else %7B%0A        cipherdata = null;
 %0A    %7D%0A%0A
@@ -432,68 +432,30 @@
     
-errormessage: %22hey%22,%0A        cipherdata: typeof(req.path%5B5%5D)
+cipherdata: cipherdata
 %0A   

Fix path to main app