Note that there are some explanatory texts on larger screens.

plurals
  1. POPass context to yield when using Meteor Iron Router
    primarykey
    data
    text
    <p>I am starting to use <a href="https://github.com/EventedMind/iron-router" rel="nofollow">Iron Router</a> in my Meteor app and its <code>yields</code> for templating.<br> I've recently run into a problem where I can't start a named yield with a context, as follows:</p> <pre><code>{{#with context}} {{yield 'subtemplate'}} {{/with}} </code></pre> <p>and get this error <code>Sorry, couldn't find a yield named "subtemplate". Did you define it in one of the rendered templates like this: {{yield "subtemplate"}}?</code></p> <p>If I remove the <code>{{#with}}</code> block expression, I am able to render the yield.</p> <p>Does anyone know of a good way to pass the context to a named yield?</p> <p>I have posted my problem as <a href="https://github.com/EventedMind/iron-router/issues/357#issuecomment-31115834" rel="nofollow">an issue</a> on the <code>iron-router</code> github project, but haven't gotten any solution yet.</p> <p>Would appreciate any help.</p> <p><strong>EDIT 1/1/2014</strong>: So my code looks like this:</p> <pre><code>// main template for the route &lt;div class="form-container"&gt; &lt;div class="form"&gt; {{yield 'section'}} &lt;/div&gt; &lt;/div&gt; </code></pre> <p>The logic to get the yield section to display</p> <pre><code>// router.js ApplyController = RouteController.extend({ before: function() { var section = this.params.section || 'personal-info'; Session.set('current', section); }, action: function() { var section = Session.get('current'); this.render(); this.render(section, { to: 'section' }); }, data: function() { return { app: Applications.findOne({user: Meteor.userId()}) } } }); </code></pre> <p>Example of one of the section template:</p> <pre><code>&lt;template name="education"&gt; {{#with app}} &lt;form id="education" name="education" class="fragment" method="post" action=""&gt; &lt;h2&gt;Education&lt;/h2&gt; &lt;div class="form-group"&gt; &lt;label for="college" class="control-label"&gt;College/ University&lt;/label&gt; &lt;select class="form-control" id="college" name="college" placeholder="Select a College/ University"&gt; &lt;option value=""&gt;Select a College/ University&lt;/option&gt; {{#each colleges}} &lt;option value="{{slug}}" {{selected slug ../college}}&gt;{{name}}&lt;/option&gt; {{/each}} &lt;/select&gt; &lt;/div&gt; &lt;!-- other content here --&gt; &lt;/form&gt; {{/with}} &lt;/template&gt; </code></pre> <p>Using the <code>{{#with app}}</code> block is how I currently get around this issue, but because I have 10 different section templates, I have to put that in all of them.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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