I am trying to write a package with its own templates. In my package.js
I am doing
api.imply([
'meteor-platform',
...
]);
api.addFiles([
'client/templates/brain_layout.html',
...
], 'client');
api.addFiles([
'client/templates/brain_layout.js',
...
], 'client');
In my brain_layout.html
I am doing
<template name="brainLayout">
<div id="wrap">
...
</div>
{{> footer}}
</template>
and in my brain_layout.js
I am doing
if (Meteor.isClient) {
Meteor.startup(function () {
console.log(Template);
console.log(Template.brainLayout);
Template.brainLayout.events({
...
});
});
}
The result is that I get an error by iron router saying Couldn't find a template named "brainLayout" or "brainLayout". Are you sure you defined it?
Couldn't find a template named "brainLayout" or "brainLayout". Are you sure you defined it?
and in the console I get TypeError: undefined is not an object (evaluating 'Template.brainLayout.events')
as well as the output of my console.log
lines. Those yield: a correctly defined Template
constructor function and an undefined Template.brainLayout
.
I have looked through several guides and stack overflow discussions but can't find the cause. Any ideas?
Make sure to api.use('templating', 'client');
in your package.js
. Without that dependency, package templates won't be recognized.
Also note that you don't need the if (Meteor.isClient)
check in brain_layout.js
if that file is only added to the client.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.