Naming Styles
-
Template, class, enum name use BigCamelCase;
-
File, identifier, function name use smallCamelCase;
-
CSS class name: css-class-name;
-
Constant value name: CONSTANT_VALUES_LIKE_THIS;
Ref:
Googe JavaScript Naming rules: use functionNamesLikeThis, variableNamesLikeThis, ClassNamesLikeThis, EnumNamesLikeThis, methodNamesLikeThis, CONSTANT_VALUES_LIKE_THIS, foo.namespaceNamesLikeThis.bar, and filenameslikethis.js.
Small Project Structure with Iron Router
The following is the file structure of small meteor app, which put all files into root folder, to simplify file editing and browsing.
-
head.html: contains "
... "; -
layout.html: defines layouts of the app, each in a "", you can put multiple layouts in this file;
-
router.js: defines all routes and layouts. Put all javascript codes starting with "Router." (such as Router.route, Router.configure) into this file;
-
collections.js: define persistent collections, or models of application;
-
style.css: defines global css styles here;
-
comTemp.html: defines global common templates here;
-
page triad: consists of a view (html), a controller (js) and a formatter (css). So the home page triad consists of home.html, home.js and home.css;
Large Project Structures
Microscope of Discover Meteor is a good example:
$ git clone https://github.com/DiscoverMeteor/Microscope.git $ cd Microscope $ tree -L 3 . ├── client │ ├── helpers │ │ ├── config.js │ │ ├── errors.js │ │ └── handlebars.js │ ├── main.html │ ├── main.js │ ├── stylesheets │ │ └── style.css │ └── templates │ ├── application │ ├── comments │ ├── includes │ ├── notifications │ └── posts ├── lib │ ├── collections │ │ ├── comments.js │ │ ├── notifications.js │ │ └── posts.js │ ├── permissions.js │ └── router.js ├── LICENSE.txt ├── README.markdown ├── README.nitrous.md └── server ├── fixtures.js └── publications.js
Ref:
Structuring your application in Meteor Docs
google "iron router layout";
Meteor Iron Router layout template
Meteor Iron-Router Layout Rendering
Set Up Navigation With Iron Router and Bootstrap
A Beginner’s Guide to Iron Router, Part 1 on Meteor Tips