Template inheritance: should this work?


#1

I found an error in my code, but I wonder if you guys think it should theoretically work.

I have a base layout template. To simplify it down, it looks like this

<template name="layout">
{{>yield "outer"}}
{{#ionView}}
  {{#ionContent}}
    {{>yield}}
  {{/ionContent}}
{{/ionView}}
</template>

Now I have a template that I am loading.

<template name="productList">
{{contentFor "outer"}}
  <input type="text" id="search"/>
{{/contentFor}}

{{#ionList}}
  // this stuff doesn't matter
{{/ionList}}
</template>

So I try to bind events to this Template.

Template.productList.events({
  'keyup input#search': _.throttle(function() {
    // not important
  }, 500)
});

This doesn’t seem to work. However, if I use Template.layout.events, it will. Is this expected behavior? Seems logical to me that “outer” would fall under the scope of productList when defining the contentFor. The most specific one could take precedence. Or at least some way to configure that.


#2

I found the same issue. not sure it is by design or just happen to be. but I am OK with it now.


#3

Although it looks like a bug thinking in terms of stock Template, thinking in terms of iron-router and multiple yield regions within the same template structure makes it perfectly understandable. It would still be nice if it worked though.

You might want to post it as an issue on iron-router’s github tracker at https://github.com/iron-meteor/iron-router/issues