Question

I have a simple list view in which I (try to) use mutache to render the output of a list containing 5 results.

function(head, req) {
  var row,
      mustache = require("vendor/couchapp/lib/mustache.js"),
      template = "<li>{{project}} {{version}} {{description}}</li>";

   while(row = getRow()) {
    send(mustache.to_html(template,row));
   }
}

This results in a timeout :

[error] [<0.22977.0>] OS Process Error <0.22858.0> :: {os_process_error,"OS process timed out."}

when I try

function(head, req) {
  var row,
      template = "<li>{{project}} {{version}} {{description}}</li>";

   while(row = getRow()) {
     send("Hello");
   }
}

this nicely prints 5x Hello.

I narrowed it down to the require statement to load the template code.

Can anyone give me a clue where the timout is coming from?

------ SOLVED -------

The require call does not like the '.js' file extension of the filename of the code to refer to.

Changing it to :

function(head, req) {
  var row,
      mustache = require("vendor/couchapp/lib/mustache"),
      template = "<li>{{project}} {{version}} {{description}}</li>";

   while(row = getRow()) {
    send(mustache.to_html(template,row));
   }
}

fixed the problem.

Was it helpful?

Solution

The require function provided adds the .js extension so it should not be given in the parameter string.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top