Skip to content
Myr

More partial() docs

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 6672d65 · Browse files · 1 file+6 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−1 removed

  • other:+6 added−1 removed

1 file+6 added−1 removed

modified:docs/guide.md+6 added-1 removed
450 unmodified lines
451452And once again even further, when rendering a collection we can simply pass453an array, if no other options are desired:454455 partial('comments', comments);455 partial('comment', comments);456457When using the partial collection support a few "magic" variables are provided458for free:459460 * _firstInCollection_ True if this is the first object461 * _indexInCollection_ Index of the object in the collection462 * _lastInCollection_ True if this is the last object463 * _collectionLength_ Length of the collection464465For documentation on altering the object name view [res.partial()](http://expressjs.com/guide.html#res-partial-view-options-).466467### Template Engines468469Below are a few template engines commonly used with Express:470
256 unmodified lines
727728The following are equivalent, and the name of collection value when passed729to the partial will be _movie_ as derived from the name.730731 partial('theatre/movie.jade', { collection: movies });732 partial('theatre/movie.jade', movies);733 partial('movie.jade', { collection: movies });734 partial('movie.jade', movies);735 partial('movie', movies);736 // In view: movie.director
183 unmodified lines