Shamoon
Shamoon

Reputation: 43501

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', {items: data, layout: false}
      res.end()
    return

I get the following error on my server:

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

Any idea?

Upvotes: 0

Views: 2277

Answers (3)

Ito
Ito

Reputation: 2167

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

Upvotes: 0

Oren
Oren

Reputation: 1006

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

Upvotes: 1

Jonathan Lonowski
Jonathan Lonowski

Reputation: 123463

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}

Upvotes: 6

Related Questions