Skip to content
Myr

New 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 74eaf3a · Browse files · 1 file+22 added−2 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+22 added−2 removed

  • other:+22 added−2 removed

1 file+22 added−2 removed

modified:docs/guide.md+22 added-2 removed
770 unmodified lines
771772Render _view_ partial with the given _options_. This method is always available773to the view as a local variable.774775- _object_ the object named by _as_ or derived from the view name775- _as_ Variable name for each _collection_ value, defaults to the view name.776- _as_ Variable name for each _collection_ or _object_ value, defaults to the view name.777 * as: 'something' will add the _something_ local variable778 * as: this will use the collection value as the template context779 * as: global will merge the collection value's properties with _locals_780
23 unmodified lines
804805Another alternative is to "explode" the properties of the collection item into806pseudo globals (local variables) by using _as: global_, which again is syntactic sugar:807807 partials('movie', { collection: movies, as: global });808 partial('movie', { collection: movies, as: global });809 // In view: director810811This same logic applies to a single partial object usage:812813 partial('movie', { object: movie, as: this });814 // In view: this.director815816 partial('movie', { object: movie, as: global });817 // In view: director818819 partial('movie', { object: movie, as: 'video' });820 // In view: video.director821822 partial('movie', { object: movie });823 // In view: movie.director824825When a non-collection (does _not_ have _.length_) is passed as the second argument, it is assumed to be the _object_, after which the object's local variable name is derived from the view name:826827 partial('movie', movie);828 // => In view: movie.director829830### app.set(name[, val])831832Apply an application level setting _name_ to _val_, or833get the value of _name_ when _val_ is not present:
161 unmodified lines