[英]Meteor doesn't serve all HTML files in a directory
While working through Meteor TODO app tutorial, I ran into a problem at step 10, Publish and Subscribe . 在浏览Meteor TODO应用程序教程时,我在第10步发布和订阅时遇到了问题。
The problem is that this code in imports/ui/task.js no longer works: 问题在于, imports / ui / task.js中的此代码不再起作用:
import { Meteor } from 'meteor/meteor'
import { Template } from 'meteor/templating';
import './task.html'; // <= fails in the browser
The directory imports/ui contains: imports / ui目录包含:
body.html body.js task.html task.js
I can import './body.html';
我可以import './body.html';
fine, but not import './task.html';
很好,但不能import './task.html';
, or any other HTML file for that matter -- eg I tried to rename task.html into flask.html and import it accordingly, and it still failed the same way. ,或与此相关的任何其他HTML文件-例如,我尝试将task.html重命名为flask.html并进行相应的导入,但仍然失败。
Trying to debug it in Chrome I found that it sees a different set of files: 尝试在Chrome中进行调试时,我发现它看到了一组不同的文件:
Looking at this question I was able to find the generated app.js , which has 看着这个问题,我能够找到生成的app.js ,它具有
Template.body.addContent((function() {
but no (expected?) 但没有(预期?)
Template.task.addContent
So my question is why Meteor build is not picking up task.html ? 所以我的问题是,为什么Meteor构建没有选择task.html ?
NOTE: I have just updated Meteor to 1.8.0.2. 注意:我刚刚将Meteor更新到1.8.0.2。 Could that be a new bug in that release? 那可能是该版本中的新错误吗?
UPDATE UPDATE
I restarted from scratch with the same tutorial and has made it through step 10 without problems. 我使用相同的教程从头开始,并顺利完成了第10步。
I then ran a diff on the two projects. 然后,我对两个项目进行了比较。 So far I was unable to find the root cause for this problem, however a cause was visible in 到目前为止,我无法找到这个问题的根本原因,但原因是可见
.meteor/local/build/programs/web.browser/app/app.js .meteor /本地/编译/程序/ web.browser /应用/ app.js
as the attached diff shows: 如所附的差异显示:
The original (on the right) is missing the section generated from task.html 原始文件(右侧)缺少task.html生成的部分
The question is still why? 问题仍然是为什么? Are there any compile logs I can look at? 我可以查看任何编译日志吗?
All right, @victor and @fred-stark were right on the money. 好的,@ victor和@ fred-stark的钱是对的。 It was a syntax error in the Blaze template! 这是Blaze模板中的语法错误!
<template name="task">
<li class="{{#if checked}}checked{{/if}} {{#if private}}private{{/if}}">
<button class="delete">×</button>
<input type="checkbox" checked="{{checked}}" class="toggle-checked" />
{{#if isOwner}}
<button class="toggle-private">
{{#if private}}
Private
{{#else}} // <= should be {{else}} !
Public
{{/if}}
</button>
{{/if}}
<span class="text"><strong>{{username}}</strong> - {{text}}</span>
</li>
</template>
I normally try to type it all myself when working on tutorials, instead of copy-paste. 我通常会在编写教程时尝试自己键入所有内容,而不是复制粘贴。 So, here I mistyped, subconsiously assuming the syntax for else
would be the same as for if
. 所以,在这里我输错,subconsiously承担语法else
将是一样的if
。 Wrong! 错误!
Still it would be nice if there was some indication from the compiler during the build process. 如果在构建过程中编译器发出了一些指示,还是很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.