[英]Does Meteor Enforce CamelCase for Template Names?
So I've a route called 'find_project' as follows: 因此,我有一条名为“ find_project”的路线,如下所示:
Router.map(function() {
this.route("/find_project");
}
And my template is as: 我的模板是:
<template name="find_project">
<h1>Find project page</h1>
</template>
Obviously, one would expect the template to work, right? 显然,人们希望模板能够正常工作,对吗? NO! 没有!
Couldn't find a template named "FindProject" or "findProject". Are you sure you defined it?
Now I camel-case the template name like so: 现在我用驼峰式命名模板名称,如下所示:
<template name="findProject">
<h1>Find project page</h1>
</template>
And magically, it started working. 神奇地,它开始起作用。
Does Meteor enforce camel casing in template names? 流星是否在模板名称中强制使用骆驼大小写?
Meteor does not enforce camel-cased names, the problem you're facing comes from iron:router
trying to guess the template name from the route path, using a camel-cased heuristic by default. 流星不强制使用驼峰式命名,您面临的问题来自iron:router
,默认情况下使用驼峰式启发式尝试从路由路径中猜测模板名称。
If you prefer underscore based names, rewrite your routing function as : 如果您希望使用基于下划线的名称,请将您的路由功能重写为:
Router.route("/find_project",{
template:"find_project"
});
Router.setTemplateNameConverter(_.identity);
来自: https : //github.com/EventedMind/iron-router/issues/1064
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.