The project I'm working on needs to be able to put custom template code in the header of certain pages (like the title of the post on postPage, for one).

I'm hoping to support this by having some logic in layout.html like

<template name="layout">
      <div class="inner-wrapper template-{{pageName}}">
        {{#if hasCustomHeader }}
           {{> Template.dynamic template=customHeader}}
        {{ else }}
          {{> header}}
        {{/if }}

and then adding the customHeader where needed.

I'm currently worried that this change is non-trivial if I try not to fork Telescope. postPage is defined in posts/lib/routes.js as

FlowRouter.route('/posts/:_id/:slug?', {
  name: "postPage",
  action: function(params, queryParams) {
    BlazeLayout.render("layout", {main: "post_page"});

When I try to overwrite the definition in my own code (by calling FlowRouter.route again), it doesn't stick. There isn't an obvious way to remove or overwrite a route in FlowRouter - I'll write one if I have to, but I worry it would rely on the implementation of _routes/_routesMap and therefore wouldn't be stable.

What do you recommend? Should I fork and submit a PR to Telescope for custom headers or should I try to get FlowRouter overwriting working?


Sacha GreifSacha Greif
last year

I don't think you necessarily need to fork Telescope. You could just use your own custom_layout and then make the header depend on a Session variable or something?

I'm not sure why you'd need to change the route though?