javascript - Meteor.js how can I use templates with the same name, multiple times -
how can use same template name multiple times across different files? have same template naming pattern every page, , problem when example <template name="defaultcontent"></template> used on page, can't used again.
example urls:
/home /home/first /home/second /home/third homepage.html
/template: homepage template: default template: first template: second template: third userpage.html
/template: userpage template: default template: first template: second template: third iron router code:
// mainpage router.route('/home', function () { this.render('homepage'); this.render('default', {to: 'content'}); }); // subpages router.route('/home/:content', function () { this.render('homepage'); var templatename = this.params.content; if(template[templatename]){ this.render(templatename, {to: 'content'}); }; }); [update] way, that's how meteor kitchen solved problem:
<template name="coolpagesubpagebsubpageb1loremipsum">
you can't define multiple templates same name.
meteor defines templates in global object, template (for example, template.homepage). object can't have multiple times same field, defining multiple times single template lead errors (possibly silent ones).
plus, how router know defaultcontent talking about?
how you?
instead of shadowing templates, define multiple templates (template.homedefault, template.userdefault) allow debug them , refer them easily.
Comments
Post a Comment