包装内的 Iron Router:找不到模板

Iron Router inside package: cannot find template

我在包内使用 Iron Router,它抱怨找不到模板,即使我已经定义了它。

我在我的包中定义了一个名为 layout 的模板:client/templates/shared/layout.html

我在 package.js 中要求该文件是这样的:

Package.onUse(function(api) {
  api.versionsFrom('1.1.0.2');

  api.use('iron:router@1.0.9');

  api.addFiles([
    'both/routes.js'
  ], ['client', 'server']);

  api.addFiles([
    'client/templates/shared/layout.html',
    'client/templates/home.html'
  ], 'client');
});

我在我的路由定义文件中使用 layout 模板,both/routes.js

Router.configure({
  layoutTemplate: 'layout'
});

Router.route('/', {
  name: 'home',
  template: 'home'
});

在我的主应用程序中,我正在使用这个包。它可以在 .meteor/packages.

找到

但是当我导航到 / 时,我得到

Couldn't find a template named "layout" or "layout". Are you sure you defined it?

我尝试重启服务器但没有成功。我错过了什么?

您可能还需要以下两个:

api.use(['templating'], 'client'); // The templating package

api.export('layout' ['client', 'server']); // Export your template.