meteor - iron-router data context passing to template -
using:
meteor 1.1.0.2
iron:router 1.0.9
i'm trying pass data router template. documentation seems point passing second param of render function. life of me can't work. work if it's second param of layout function.
upon reading, seems preferred way pass data via router rather make helper. also, have globally configured template use, layout() won't declared if i'm using layout in router.config.
please correct misconceptions.
so, here's template html:
<div class="col-sm-12 col-md-12"> <p>pagetitle: {{pagetitle}}</p> </div>
now want static rather result set find() on database.
here's snippet in router.js. not work thought:
router.route('/tour', function(){ console.log("this tour page"); // works this.layout('marketing'); // different config calls this.render('tour', { data: function(){ return {pagetitle:'tour12'}; // template not see } }); },{ name: 'marketing.tour' });
if rewrite folowing, variable populated expected:
router.route('/tour', function(){ console.log("this tour page"); this.layout('marketing', { data: function(){ return {pagetitle:'tour12'}; } }); this.render('tour'); },{ name: 'marketing.tour' });
i've tried passing params object no avail (which seems great way pass attributes):
router.route('/tour',{ name: 'marketing.tour', layout: 'marketing', data: {pagetitle:'tour12'}, render: 'tour' });
so, making incorrect assumptions? should following different/better design pattern? need call this.layout()
everytime want pass data context? seems if router.map() has been depreciated (as many examples indicate 1 way inject data template? further thoughts?
thank you.
Comments
Post a Comment