Meteor是否为模板名称强制使用CamelCase?

时间:2014-12-07 11:02:39

标签: javascript meteor iron-router spacebars

所以我有一条名为“find_project'如下:

Router.map(function() {
  this.route("/find_project");
}

我的模板如下:

<template name="find_project">
  <h1>Find project page</h1>
</template>

显然,人们会期望模板能够正常工作,对吧? NO!

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

现在我的模板名称如下所示:

<template name="findProject">
  <h1>Find project page</h1>
</template>

神奇地,它开始工作了。

Meteor是否在模板名称中强制执行骆驼套管?

2 个答案:

答案 0 :(得分:2)

Meteor不会强制使用驼峰式名称,您遇到的问题来自iron:router尝试从路径路径猜测模板名称,默认情况下使用驼峰式启发式。

如果您更喜欢基于下划线的名称,请将路由功能重写为:

Router.route("/find_project",{
  template:"find_project"
});

答案 1 :(得分:0)

Router.setTemplateNameConverter(_.identity);

来自:https://github.com/EventedMind/iron-router/issues/1064