包中的Iron Router:找不到模板 [英] Iron Router inside package: cannot find template
问题描述
我在包装内使用Iron Router,尽管它定义了模板,但它抱怨找不到模板.
I am using Iron Router inside a package, and it complains that it cannot find a template, even though I have defined it.
我在包中定义了一个名为layout
的模板:client/templates/shared/layout.html
I have defined a template called layout
inside my package: client/templates/shared/layout.html
我已经要求在package.js
中添加该文件,如下所示:
And I have required that file in package.js
like this:
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');
});
并且我在路径定义文件both/routes.js
And I am using layout
template in my route definition file, both/routes.js
Router.configure({
layoutTemplate: 'layout'
});
Router.route('/', {
name: 'home',
template: 'home'
});
在我的主应用程序中,我正在使用此软件包.可以在.meteor/packages
上找到.
And in my main app, I am using this package. It can be found at .meteor/packages
.
但是当我导航到/
时,我得到了
But when I navigate to /
, I get
Couldn't find a template named "layout" or "layout". Are you sure you defined it?
我尝试重新启动服务器,但没有成功.我想念什么?
I tried to restart the server without success. What am I missing?
推荐答案
您可能还需要以下两个:
You might also need the following two:
api.use(['templating'], 'client'); // The templating package
api.export('layout' ['client', 'server']); // Export your template.
这篇关于包中的Iron Router:找不到模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!