开发者

Why don't partials work in ExpressJS?

  myModule.search location, item, (err, data) ->
    if err?
      res.end 'Error!'
    else
      res.write 'got here'
      partial 'partials/table', {i开发者_如何转开发tems: data, layout: false}
      res.end()
    return

I get the following error on my server:

        partial('partials/table', {
        ^
ReferenceError: partial is not defined

Any idea?


While the examples in the guide demonstrate it as a global function, I think it's only actually available like this within a view:

#data-view
  != partial('datalist', { collection: data })

You can find a number of examples of this under /examples/partials in the repository.

Within your script, however, it's a method of the response object:

res.partial 'partials/table', {items: data, layout: false}


I see that it changed a little. You need to investigate extends ../layout, block content and include.

Search for the examples in:

https://github.com/visionmedia/express/blob/master/examples/jade


Partials are no longer available for 3.0+ Express JS version. So you have to check out for includes that contains the same conception.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜