Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You pass a data context in the router using ironrouter. You can't pass it this way because if you pass a route in the router it would override the route's data context.</p> <p>It might however work with the shark branch of ironRouter which is based off Meteor UI since it uses <code>{{&gt;yield}}</code> instead of <code>{{yield}}</code>.</p> <p>You can use this though:</p> <h3>Route specific data context</h3> <pre><code>Router.map(function() { this.route('template', data: function() { return Something.find() }); }); </code></pre> <p>You basically pass the context using the <code>data</code> param. It might be easier to do it this way than to use <code>{{#with context}}</code> because you can use more dynamic data which is different for each route.</p> <p>You might have tried this, I'm a bit unsure on whether it would go to a named yield's template.</p> <h3>Using an ordinary Template helper for the template</h3> <pre><code>Template.templateInYieldName.helper = function() { return Something.find(); } </code></pre> <p>Then you can use something like <code>{{helper.name}}</code> in your named yield.</p> <h3>Global data context with handlebars helper</h3> <p>If you intend to use data for all the routes you can use a Handlebars global helper. i.e</p> <pre><code>Handlebars.registerHelper('todaysDate', function() { return (new Date).toString(); }); </code></pre> <p>then just use <code>{{todaysDate}}</code> in any of your templates. You can use your data instead of a date instead.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload