【发布时间】:2014-12-07 17:37:31
【问题描述】:
最近在研究meteor js框架,想为meteor写一个包,但是在尝试一个包的时候,模板有问题
在我的 package.js 中
api.use([
'templating',
"coffeescript",
], "client");
api.addFiles([
'client/breadcrumb.coffee',
'client/helpers.coffee',
'client/views/breadcrumb/crumb.html'
], 'client');
api.use(['coffeescript'], 'server');
api.addFiles('server/breadcrumb.coffee', 'server');
在我的 helper.coffee 中,我使用如下 sn-p 代码:
Template.breadcrumbs.helpers ->
crumbs: () ->
Breadcrumb.getCrumbs()
当我在我的应用程序中包含我的包时,它不起作用。 这是错误:
Uncaught ReferenceError: Template is not defined helpers.coffee:1
Uncaught TypeError: Cannot read property 'Breadcrumb' of undefined global-imports.js:13
Uncaught ReferenceError: Template is not defined template.dashboard_category.js:2
Uncaught ReferenceError: Template is not defined template.dashboard_contact.js:2
Uncaught ReferenceError: Template is not defined template.dashboard_contact_detail.js:2
Uncaught ReferenceError: Template is not defined template.dashboard_post.js:2
Uncaught ReferenceError: Template is not defined template.dashboard_post_form.js:2
Uncaught ReferenceError: Template is not defined template.dashboard_user.js:2
Uncaught ReferenceError: Template is not defined template.about.js:2
Uncaught ReferenceError: Template is not defined template.contact.js:2
Uncaught ReferenceError: Template is not defined template.dashboard.js:2
Uncaught ReferenceError: Template is not defined template.home.js:2
Uncaught ReferenceError: Template is not defined template.dashboard.js:2
Uncaught ReferenceError: Template is not defined template.layout.js:2
Uncaught ReferenceError: Template is not defined template.404.js:2
Uncaught ReferenceError: Template is not defined template.dashboard_breadcrumb.js:2
Uncaught ReferenceError: Template is not defined template.dashboard_header.js:2
Uncaught ReferenceError: Template is not defined template.dashboard_slidebar.js:2
Uncaught ReferenceError: Template is not defined template.flash.js:2
Uncaught ReferenceError: Template is not defined template.footer.js:2
Uncaught ReferenceError: Template is not defined template.header.js:2
Uncaught ReferenceError: Template is not defined template.loading.js:2
Uncaught ReferenceError: Deps is not defined dashboard_category.coffee.js:2
Uncaught ReferenceError: Deps is not defined dashboard_contact.coffee.js:2
Uncaught ReferenceError: Deps is not defined dashboard_post.coffee.js:2
Uncaught ReferenceError: Meteor is not defined dashboard_user.coffee.js:2
Uncaught ReferenceError: Template is not defined dashboard.coffee.js:2
Uncaught ReferenceError: Meteor is not defined client.coffee.js:2
Uncaught ReferenceError: Meteor is not defined collections.js:3
Uncaught ReferenceError: SimpleSchema is not defined schema.js:6
Error: Spacebars is not defined
ReferenceError: Spacebars is not defined
at null._render (http://localhost:3000/packages/accounts-ui-unstyled.js?724142103f86896bf7ab0a57672b34086f989b24:634:12)
at doRender (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1853:25)
at http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1795:16
at Object.Blaze._withCurrentView (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:2029:12)
at viewAutorun (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1794:18)
at Tracker.Computation._compute (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:288:36)
at new Tracker.Computation (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:206:10)
at Object.Tracker.autorun (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:476:11)
at Blaze.View.autorun (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1793:19)
at http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1847:10
> Before: 630ms (diff: 630ms)
at http://localhost:3000/packages/meteor.js?012a26290d9cb731a3b52b396e571c8159d11236:738:12
at http://localhost:3000/packages/meteor.js?012a26290d9cb731a3b52b396e571c8159d11236:774:4
at http://localhost:3000/packages/meteor.js?012a26290d9cb731a3b52b396e571c8159d11236:1022:3
> Before: 676ms (diff: 46ms)
at Array.forEach (native) reporters.js?1413185929295:67
Error: Exception in defer callback:
ReferenceError: Spacebars is not defined
at null._render (http://localhost:3000/packages/iron_layout.js?080dc95e770e3130757bf6af69fd0abb99573ae4:95:10)
at doRender (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1853:25)
at http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1795:16
at Object.Blaze._withCurrentView (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:2029:12)
at viewAutorun (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1794:18)
at Tracker.Computation._compute (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:288:36)
at new Tracker.Computation (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:206:10)
at Object.Tracker.autorun (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:476:11)
at Blaze.View.autorun (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1793:19)
at http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1847:10
> Before: 657ms (diff: 657ms)
at usePostMessage (http://localhost:3000/packages/meteor.js?012a26290d9cb731a3b52b396e571c8159d11236:376:12)
at http://localhost:3000/packages/meteor.js?012a26290d9cb731a3b52b396e571c8159d11236:405:3
at http://localhost:3000/packages/meteor.js?012a26290d9cb731a3b52b396e571c8159d11236:410:4
at http://localhost:3000/packages/meteor.js?012a26290d9cb731a3b52b396e571c8159d11236:1022:3
【问题讨论】:
-
面包屑模板本身是否在 crumbs.html 中?如果是这样,您需要在添加 helpers.coffee 之前添加 html 文件。我认为您可以通过更改数组顺序来做到这一点,但我会将其分成两个
api.addFiles调用,首先添加 crumbs.html。
标签: meteor meteor-blaze