You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _controller/action.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -15,4 +15,4 @@ module.exports = {
15
15
};
16
16
```
17
17
18
-
The example above will have add the `index` action to the `users_controller`. To hookup the controller's action to a route simply add `addRoute('/users', 'users#index')` to the [app/routes.js](/router#routes.js) file.
18
+
The example above will add the `index` action to the `users_controller`. To connect the controller's action to a route, simply add `addRoute('/users', 'users#index')` to the [app/routes.js](/router#routes.js) file.
Copy file name to clipboardExpand all lines: _controller/name.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,8 @@
2
2
header: name
3
3
---
4
4
5
-
All controllers are required to have the `_controller.js`post-fix. The name of the controller is the filename before the post-fix.
5
+
All controllers are required to have the `_controller.js`postfix. The name of the controller is the filename before the postfix.
6
6
7
-
For example: `users_controller.js` has the name `users`.
7
+
For example: `users_controller.js` has the name `users`.
8
8
9
-
This is a convention, and doesn't actually have an attribute stored, the [router](/router) uses it to generate the handler in [addRouteDefinition](/router#addRouteDefinition).
9
+
The [router](/router) uses this naming convention to generate the handler in [addRouteDefinition](/router#addRouteDefinition), but a `name` attribute isn't actually stored.
Copy file name to clipboardExpand all lines: controller/index.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -5,14 +5,14 @@ title: Controller - RendrJS
5
5
6
6
# Controller
7
7
8
-
Controllers are an addition to Rendr that doesn't exist in Backbone. Controllers allow us to have a cleaner [router](/router). Controllers define functions that the router will invoke when a URL is visited. The functions that are invoked are called [actions](#action).
8
+
Controllers are an addition to Rendr that do not exist in Backbone. Controllers define functions (known as [actions](#action)) that the [router](/router) will invoke when a URL is visited. This allows us to have a cleaner router.
9
9
10
-
Controllers have no base class, as they are simply objects where the values are functions. Simply create files in the `controllers/` directory of your application and follow the naming convention: `<name>_controller.js`. The [name](#name) is how the router will know which file to open. The keys of the object being exported are the [actions](#action) for a controller.
10
+
Controllers have no base class, as they are simply objects containing functions. Simply create files in the `controllers/` directory of your application and follow the naming convention: `<name>_controller.js`. The [name](#name) is how the router will know which file to open. The keys of the object being exported are the [actions](#action) for a controller.
11
11
12
12
Example Controller:
13
13
14
14
```js
15
-
//contollers/users_controller.js
15
+
//controllers/users_controller.js
16
16
module.exports= {
17
17
index:function(params, callback) {
18
18
var spec = {
@@ -44,9 +44,9 @@ module.exports = {
44
44
};
45
45
```
46
46
47
-
The above example creates a controller with two actions, `index` and `show`. The `index` action will simply display all the users, and the `show` action will show a specific user, by their id.
47
+
The above example creates a controller with two actions, `index` and `show`. The `index` action will display all the users, and the `show` action will show a specific user by their id.
48
48
49
-
The example's matching[routes.js](/router#routes.js) file:
0 commit comments