Ember.js项目目录结构

时间:2012-12-30 23:02:29

标签: ember.js

是否有任何好的教程或Ember.js文档描述了模型/视图/控制器的目录结构,app.js以及在index.html根文件中引用这些文件的方法。

  • 要创建“Ember.Application.create”的文件?
  • 包含顺序(models.js,apps.js,controllers.js)?

4 个答案:

答案 0 :(得分:4)

This tutorial by Dan Gebhardt对我设置项目结构和确定如何包含文件非常有帮助。

答案 1 :(得分:4)

ember-skeleton project有一个合理的rake管道项目布局示例。他们这样做(from the README):

ember-skeleton
├── Assetfile - App build file
├── Gemfile - Package dependencies for rakep/rack
├── Gemfile.lock - Here be dragons: don't touch, always include
├── app - App specific code
│   ├── css - App CSS or SCSS (.scss)
│   ├── lib - App code, *modularized during build*
│   ├── modules - Module code, *already modularized*
│   ├── plugins - Plugins (e.g. jquery.jsonrpc.js)
│   │   └── loader.js - JS module loader
│   ├── static - Static files, never touched, copied over during build
│   ├── templates - Handlebars templates, *modularized during build*
│   ├── tests - QUnit application tests
│   └── vendor - Vendor code, *modularized during build*
├── assets - Built out asset files, minified in production
│   ├── app.css - Built out app CSS/SCSS
│   ├── app.js - Built out app JS
│   └── loader.js - Built out JS module loader
├── config.ru - Rack development web server configuration
├── index.html - The app entry point
├── tests - QUnit testing files
│   ├── index.html - The testing entry point
│   ├── qunit - Testing support files
│   └── run-tests.js - The PhantomJS QUnit test runner
└── tmp - Temporary build files used by rakep

答案 2 :(得分:4)

我有一个我很满意的布局

app.js - 这是主要的应用程序文件,包括设置和路由器

views.js - 包含应用程序中使用的视图,虽然我现在通常将其拆分为homeView.js navigtaionView.js等

dataModels.js - 这是我保存应用程序的所有数据模型对象的地方

dataSources.js - 我使用它从我制作的任何api调用中加载数据模型或数据模型数组

accountController.js - 控制器类,在附件中我还有一个emailMessagingController和一个smsMessagingController

您可以在此处找到我的示例项目

https://github.com/bwship/neptunejs

和这里的ember的coffeescript文件

https://github.com/bwship/neptunejs/tree/master/public/coffeescripts

最后是布局和索引的jad文件,显示我如何在这里添加这些

https://github.com/bwship/neptunejs/tree/master/views

我确实希望最终开始使用ember数据样式,但是已经使用dataSources和dataModels文件推出了一些可靠的应用程序。

答案 3 :(得分:2)

似乎还没有明确的惯例,但目前很多人似乎都在使用Yeoman和官方的Ember发电机https://github.com/yeoman/generator-ember

虽然我很欣赏Ember教程的“开放”特性,但Rails的一个好处是文件放置的惯例。当我们聘请一位新的开发人员时,我们不需要对我们的目录结构做出解释......我希望Ember很快就会制定官方标准。

相关问题