Fixed partials example
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 bd1ab7a · Browse files · 9 files·+33 added−34 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
9 files+33 added−34 removed
- other:+33 added−34 removed
Provenance
- Commit
d5b7a40- Tree
7c9b7b3- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
bd1ab7a
9 files changed+33 added−34 removed
added:examples/partials/views/ninja/victim/index.jade+5 added
1+// this is insane overkill, I do not recommend2+// doing tiny partials like this as it gets expensive3+// with collections, however this illustrates the new4+// partial lookup mechanism5+!= partial('../../li', { object: victim, as: 'value' })added:examples/partials/views/ninja/_weapon.jade+1 added
1+li.weapon= weaponadded:examples/partials/views/ninja/index.jade+22 added
1+h1= ninja.name2+3+// file, partial name, and partial object all match ('summary')4+// the partial filename prefix '_' is completely optional.5+6+// In this case we need to specify ninja.summary as the object7+// option, since it is a "plain" object Express cannot otherwise8+// tell if it is intended to be locals, or THE summary object9+#summary!= partial('summary', { object: ninja.summary })10+11+// file, partial name = '_weapon', resolves to 'weapon' object within partial12+#weapons13+ h2 Weapons14+ // the weapon partial is rendered once per item in15+ // the weapons array or "collection"16+ ul!= partial('weapon', ninja.weapons)17+ 18+// partial name 'victim' resolves to 'victim.jade'19+// or 'victim/index.jade', providing the "victim" local20+#victims21+ h2 Victims22+ ul!= partial('victim', ninja.victims)added:examples/partials/views/ninja/summary.jade+4 added
1+h2 Summary2+p= summary.email3+p= summary.description4+p taught by master #{summary.master}deleted:examples/partials/views/ninjas/victim/index.jade-5 removed
1-// this is insane overkill, I do not recommend2-// doing tiny partials like this as it gets expensive3-// with collections, however this illustrates the new4-// partial lookup mechanism5-!= partial('../../li', { object: victim, as: 'value' })deleted:examples/partials/views/ninjas/_weapon.jade-1 removed
1-li.weapon= weapondeleted:examples/partials/views/ninjas/index.jade-18 removed
1-h1= ninja.name2-3-// file, partial name, and partial object all match ('summary')4-// the partial filename prefix '_' is completely optional5-#summary!= partial('summary', ninja.summary)6-7-// file, partial name = '_weapon', resolves to 'weapon' object within partial8-#weapons9- h2 Weapons10- // the weapon partial is rendered once per item in11- // the weapons array or "collection"12- ul!= partial('weapon', ninja.weapons)13- 14-// partial name 'victim' resolves to 'victim.jade'15-// or 'victim/index.jade', providing the "victim" local16-#victims17- h2 Victims18- ul!= partial('victim', ninja.victims)deleted:examples/partials/views/ninjas/summary.jade-4 removed
1-h2 Summary2-p= summary.email3-p= summary.description4-p taught by master #{summary.master}modified:examples/partials/app.js+1 added-6 removed
26 unmodified lines27 victims: ['shredder', 'brain', 'beebop', 'rocksteady']28 };29 30 app.get('/', function(req, res){31- res.render('ninjas', { ninja: ninja });31+ res.render('ninja', { ninja: ninja });32 });33 34-app.get('/li', function(req, res){35- res.partial('li', { object: 'Testing', as: 'value' });36-});37-38-34 app.listen(3000);35 console.log('Express app started on port 3000');