veliovgroup / flow-router

🚦 Carefully extended flow-router for Meteor
https://packosphere.com/ostrio/flow-router-extra
BSD 3-Clause "New" or "Revised" License
202 stars 29 forks source link

Template.layout is undefined #51

Closed tvogt closed 6 years ago

tvogt commented 6 years ago

I'm having an issue:

  - set up initial page according to your instructions
  - error message in console on loading a page:

TypeError: Template.layout is undefined default.js:6

where default.js is:

import { Template } from 'meteor/templating'; import './default.html';

// As example all available Template's callbacks // layout should be considered as a regular template Template.layout.onCreated(function () { / ... / }); Template.layout.onRendered(function () { / ... / }); Template.layout.onDestroyed(function () { / ... / }); Template.layout.helpers({ / ... / }); Template.layout.events({ / ... / });



missing a dependency, maybe?
tvogt commented 6 years ago

my mistake, or something that could be made more clear in the documentation.

solution:

Template.default.onCreated(function () { /* ... */ });
Template.default.onRendered(function () { /* ... */ });
Template.default.onDestroyed(function () { /* ... */ });
Template.default.helpers({ /* ... */ });
Template.default.events({ /* ... */ });

must use the name of the template. I wrongly assumed that "layout" is a built-in function.

dr-dimitru commented 6 years ago

Hello @tvogt ,

I'm glad you've figured it out on your own. Our Templating docs starts with create layout.