Search code examples
meteoriron-router

How to reuse layoutTemplate between routes?


Looking at devtools profiling, when I move between two routes with the same layoutTemplate, the layout's helpers are being rerun, and it looks like the HTML is being rerendered as well. How can I have iron router only render the yields and leave the layout alone?

EDIT code:

Router.map ->
  @route '/foo',
    layoutTemplate: 'headered'

  @route '/bar',
    layoutTemplate: 'headered'

Template.headered.helpers 
  test: ->
    console.log 'gets run when switching from /foo to /bar'

<template name="headered">
  {{test}}

  <header>
    {{getReactiveData}}
  </header>

  {{> yield}}
</template>

I don't want the <header> node to be rerendered. I don't want getReactiveData to be called when the route changes (only when the data changes).


Solution

  • There's something abnormal about my app, because IR doesn't normally rerender the layout between routes:

    http://meteorpad.com/pad/qcu8QWASvPEjDEf5k/IR