我想知道是否可以将特定文件夹设置为路径/视图/模板/控制器的根路径?
例如,我的项目看起来像这样:
/controllers
/base
/main
/index.js
/welcome
/index.js
/routes
/base
/main
/index.js
/welcome
/index.js
/templates
/main
/index.hbs
/welcome
/index.hbs
/views
/base
/main
/index.js
/welcome
/index.js
我的main
文件夹是我所有控制器,路由,模板和视图的根文件夹。
使用网址:
mywebsite.com
将访问/main/index.js
mywebsite.com/welcome
将访问/main/welcome/index.js
由于
答案 0 :(得分:5)
您可以通过为根路径提供空路径来完成此操作:
Router.map(function() {
this.resource('main', { path: '' }, function() {
this.resource('main.welcome', { path: 'welcome' }, function() {});
});
});
mywebsite.com
为您提供main/index.js
,mywebsite.com/welcome
为您提供main/welcome/index.js
。