【问题标题】:Timeout in a Couchapp list when using mustache使用 mustache 时 Couchapp 列表中的超时
【发布时间】:2010-09-29 14:22:34
【问题描述】:

我有一个简单的列表视图,我(尝试)在其中使用 mutache 来呈现包含 5 个结果的列表的输出。

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));
   }
}

这会导致超时:

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

当我尝试时

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

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

这很好地打印了 5x Hello。

我将范围缩小到加载模板代码的 require 语句。

谁能告诉我超时来自哪里?

--------解决了--------

require 调用不喜欢'.js' 文件扩展名的代码文件名来引用。

改成:

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));
   }
}

解决了问题。

【问题讨论】:

    标签: javascript couchdb mustache couchapp


    【解决方案1】:

    提供的 require 函数添加了 .js 扩展名,因此不应在参数字符串中给出。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-12
      • 1970-01-01
      相关资源
      最近更新 更多