paloma 1.2.6 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. data/.gitignore +2 -3
  2. data/Changelog.md +0 -4
  3. data/README.md +206 -67
  4. data/app/templates/_filters.js +14 -0
  5. data/app/templates/application/_locals.js +13 -0
  6. data/app/templates/controller/_locals.js +19 -0
  7. data/app/templates/controller/_manifest.js +3 -0
  8. data/app/templates/controller/action.js +23 -0
  9. data/app/templates/index.js +3 -1
  10. data/app/templates/namespace/_locals.js +16 -0
  11. data/app/templates/namespace/_manifest.js +3 -0
  12. data/app/views/paloma/_callback_hook.html.erb +31 -26
  13. data/lib/paloma.rb +3 -0
  14. data/lib/paloma/action_controller_extension.rb +18 -16
  15. data/lib/paloma/action_controller_filters.rb +4 -7
  16. data/lib/paloma/generators/add_generator.rb +81 -85
  17. data/lib/paloma/generators/setup_generator.rb +15 -5
  18. data/lib/paloma/rails/controller_generator.rb +11 -0
  19. data/lib/paloma/rails/engine.rb +6 -0
  20. data/paloma.gemspec +1 -3
  21. data/spec/test_app/.gitignore +15 -0
  22. data/spec/test_app/.rspec +1 -0
  23. data/spec/test_app/Gemfile +2 -0
  24. data/spec/test_app/README.rdoc +261 -0
  25. data/spec/test_app/Rakefile +16 -0
  26. data/spec/test_app/app/assets/javascripts/application.js +16 -0
  27. data/spec/test_app/app/assets/javascripts/paloma/_filters.js +130 -0
  28. data/spec/test_app/app/assets/javascripts/paloma/_locals.js +17 -0
  29. data/spec/test_app/app/assets/javascripts/paloma/bar/_filters.js +96 -0
  30. data/spec/test_app/app/assets/javascripts/paloma/bar/_locals.js +1 -0
  31. data/spec/test_app/app/assets/javascripts/paloma/bar/_manifest.js +3 -0
  32. data/spec/test_app/app/assets/javascripts/paloma/bar/another_basic_action.js +5 -0
  33. data/spec/test_app/app/assets/javascripts/paloma/bar/basic_action.js +5 -0
  34. data/spec/test_app/app/assets/javascripts/paloma/bar/different_params.js +4 -0
  35. data/spec/test_app/app/assets/javascripts/paloma/bar/yet_another_basic_action.js +5 -0
  36. data/spec/test_app/app/assets/javascripts/paloma/foo/_filters.js +24 -0
  37. data/spec/test_app/app/assets/javascripts/paloma/foo/_locals.js +21 -0
  38. data/spec/test_app/app/assets/javascripts/paloma/foo/_manifest.js +3 -0
  39. data/spec/test_app/app/assets/javascripts/paloma/foo/basic_action.js +21 -0
  40. data/spec/test_app/app/assets/javascripts/paloma/foo/skip_callback.js +6 -0
  41. data/spec/test_app/app/assets/javascripts/paloma/index.js +6 -0
  42. data/spec/test_app/app/assets/javascripts/paloma/sample_namespace/_filters.js +83 -0
  43. data/spec/test_app/app/assets/javascripts/paloma/sample_namespace/_manifest.js +2 -0
  44. data/spec/test_app/app/assets/javascripts/paloma/sample_namespace/baz/_filters.js +84 -0
  45. data/spec/test_app/app/assets/javascripts/paloma/sample_namespace/baz/_locals.js +1 -0
  46. data/spec/test_app/app/assets/javascripts/paloma/sample_namespace/baz/_manifest.js +2 -0
  47. data/spec/test_app/app/assets/javascripts/paloma/sample_namespace/baz/another_basic_action.js +5 -0
  48. data/spec/test_app/app/assets/javascripts/paloma/sample_namespace/baz/basic_action.js +5 -0
  49. data/spec/test_app/app/assets/javascripts/paloma/sample_namespace/baz/yet_another_basic_action.js +5 -0
  50. data/spec/test_app/app/controllers/application_controller.rb +3 -0
  51. data/spec/test_app/app/controllers/bar_controller.rb +28 -0
  52. data/spec/test_app/app/controllers/foo_controller.rb +25 -0
  53. data/spec/test_app/app/controllers/sample_namespace/baz_controller.rb +23 -0
  54. data/spec/{sample_app → test_app}/app/views/layouts/application.html.erb +0 -0
  55. data/spec/test_app/config.ru +4 -0
  56. data/spec/test_app/config/application.rb +74 -0
  57. data/spec/test_app/config/boot.rb +6 -0
  58. data/spec/test_app/config/environment.rb +5 -0
  59. data/spec/test_app/config/environments/development.rb +31 -0
  60. data/spec/test_app/config/environments/production.rb +64 -0
  61. data/spec/test_app/config/environments/test.rb +35 -0
  62. data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
  63. data/spec/test_app/config/initializers/inflections.rb +15 -0
  64. data/spec/test_app/config/initializers/mime_types.rb +5 -0
  65. data/spec/test_app/config/initializers/secret_token.rb +7 -0
  66. data/spec/test_app/config/initializers/session_store.rb +8 -0
  67. data/spec/test_app/config/initializers/wrap_parameters.rb +10 -0
  68. data/spec/test_app/config/locales/en.yml +5 -0
  69. data/spec/test_app/config/routes.rb +33 -0
  70. data/spec/test_app/log/.gitkeep +0 -0
  71. data/spec/test_app/public/404.html +26 -0
  72. data/spec/test_app/public/422.html +26 -0
  73. data/spec/test_app/public/500.html +25 -0
  74. data/spec/test_app/public/favicon.ico +0 -0
  75. data/spec/test_app/public/robots.txt +5 -0
  76. data/spec/test_app/script/rails +6 -0
  77. data/spec/test_app/spec/generator_helper.rb +87 -0
  78. data/spec/test_app/spec/generators/paloma_generator_spec.rb +199 -0
  79. data/spec/test_app/spec/generators/rails_generator_spec.rb +54 -0
  80. data/spec/test_app/spec/javascripts/callback_spec.rb +64 -0
  81. data/spec/test_app/spec/javascripts/filters_spec.rb +187 -0
  82. data/spec/test_app/spec/javascripts/locals_spec.rb +27 -0
  83. data/spec/test_app/spec/javascripts/params_spec.rb +116 -0
  84. data/spec/test_app/spec/javascripts/skip_filters_spec.rb +58 -0
  85. data/spec/test_app/spec/javascripts/variable_container_spec.rb +21 -0
  86. data/spec/test_app/spec/spec_helper.rb +26 -0
  87. data/vendor/assets/javascripts/paloma_core.js +294 -0
  88. metadata +79 -68
  89. data/Rakefile +0 -28
  90. data/app/templates/_callbacks.js +0 -2
  91. data/app/templates/_local.js +0 -20
  92. data/app/templates/action.js +0 -5
  93. data/app/templates/paloma.js +0 -22
  94. data/spec/callback_spec.rb +0 -81
  95. data/spec/generator_spec.rb +0 -425
  96. data/spec/sample_app/app/assets/javascripts/application.js +0 -4
  97. data/spec/sample_app/app/assets/javascripts/paloma/articles/_callbacks.js +0 -1
  98. data/spec/sample_app/app/assets/javascripts/paloma/articles/create.js +0 -3
  99. data/spec/sample_app/app/assets/javascripts/paloma/articles/edit.js +0 -3
  100. data/spec/sample_app/app/assets/javascripts/paloma/articles/index.js +0 -3
  101. data/spec/sample_app/app/assets/javascripts/paloma/articles/new.js +0 -3
  102. data/spec/sample_app/app/assets/javascripts/paloma/articles/show.js +0 -3
  103. data/spec/sample_app/app/assets/javascripts/paloma/articles/update.js +0 -3
  104. data/spec/sample_app/app/assets/javascripts/paloma/index.js +0 -3
  105. data/spec/sample_app/app/assets/javascripts/paloma/paloma.js +0 -1
  106. data/spec/sample_app/app/assets/javascripts/paloma/sample_namespace/_callbacks.js +0 -1
  107. data/spec/sample_app/app/assets/javascripts/paloma/sample_namespace/categories/_callbacks.js +0 -1
  108. data/spec/sample_app/app/assets/javascripts/paloma/sample_namespace/categories/index.js +0 -3
  109. data/spec/sample_app/app/views/articles/index.html.erb +0 -5
  110. data/spec/sample_app/app/views/articles/new.html.erb +0 -9
  111. data/spec/sample_app/app/views/articles/show.html.erb +0 -2
  112. data/spec/sample_app/app/views/sample_namespace/categories/index.html.erb +0 -5
  113. data/spec/sample_app/app/views/sample_namespace/categories/new.html.erb +0 -5
  114. data/spec/sample_app/controllers.rb +0 -68
  115. data/spec/sample_app/init.rb +0 -37
  116. data/spec/sample_app/models.rb +0 -40
  117. data/spec/spec_helper.rb +0 -21
  118. data/spec/test_app/log/development.log +0 -4
  119. data/spec/test_app/tmp/cache/assets/CF0/DA0/sprockets%2Fd7d5b37686831d37c4dd75e645f5e016 +0 -0
  120. data/spec/test_app/tmp/cache/assets/E25/4C0/sprockets%2Fde2fd9fd11c04a582cdbbe3d84a35ae6 +0 -0
data/.gitignore CHANGED
@@ -2,6 +2,5 @@ Gemfile.lock
2
2
  *.gem
3
3
  /tmp/*
4
4
  /spec/tmp/
5
- /spec/sample_app/tmp/
6
- /spec/sample_app/log/
7
- /spec/sample_app/paloma_test
5
+ /spec/test_app/tmp
6
+ /spec/test_app/spec/tmp/*
@@ -1,10 +1,6 @@
1
1
  Changelog
2
2
  =
3
3
 
4
- Version 1.2.6
5
- -
6
- * Paloma hook script is not appended on the response when `false` is passed to `js_callback`
7
-
8
4
  Version 1.2.0
9
5
  -
10
6
  * AddGenerator with multiple actions: `rails g paloma:add namespace/controller action1 action2 action3`
data/README.md CHANGED
@@ -1,21 +1,23 @@
1
1
  Paloma
2
2
  ======
3
- Paloma provides a sexy way to organize javascript files using Rails' asset pipeline.
4
- It adds the capability to execute page-specific javascript code after rendering the controller's response.
3
+ Paloma provides a sexy and logical way of organizing Rails javascript files.
4
+ Its core feature is a powerful yet simple way to execute page-specific javascript code.
5
+
6
+ But there are more sexy features Paloma has to offer!
5
7
 
6
8
  Advantages
7
9
  -
8
10
  * Javascript files are organized per controller just like app/views folder of Rails.
9
11
  * Javascript file per controller's action.
10
- * The ability to choose what specific javascript code to run on a specific action.
12
+ * Choose what specific javascript codes to run per page.
11
13
  * Easily make ruby variables available on your javascript files.
12
14
 
13
15
  Quick Example
14
16
  -
15
- The javascript callback file `app/assets/javascripts/paloma/users/new.js`:
17
+ The javascript callback file `/assets/javascripts/paloma/users/new.js`:
16
18
 
17
19
  ```javascript
18
- Paloma.callbacks['users/new'] = function(params){
20
+ Paloma.callbacks['users']['new'] = function(params){
19
21
  // This will only run after executing users/new action
20
22
  alert('Hello New Sexy User');
21
23
  };
@@ -28,6 +30,7 @@ def UsersController < ApplicationController
28
30
  def new
29
31
  @user = User.new
30
32
  # No special function to call, the javascript callback will be executed automatically
33
+ # just for this specific action.
31
34
  end
32
35
  end
33
36
  ```
@@ -64,27 +67,28 @@ Require `paloma` in your `application.js`:
64
67
  //= require paloma
65
68
  ```
66
69
 
67
- Directory Structure
70
+ Basic Directory Structure
68
71
  -
69
72
  `paloma` folder contains the javascript callbacks.
70
73
 
71
74
  * paloma
72
- * [controllers]
75
+ * [controller]
73
76
  * [action].js
74
77
  * [other_action].js
75
- * [other_controllers]
78
+ * [other_controller]
76
79
  * [action].js
77
80
  * [other_action].js
78
81
  * [more_action].js
79
82
  * [namespace]
80
- * [controllers]
83
+ * [controller]
81
84
  * [action].js
82
85
 
83
86
  Generators
84
87
  -
85
- 1. Generate a controller folder containing its required files:
88
+
89
+ 1. Generate a controller folder containing its required files:
86
90
  ```
87
- rails g paloma:add [controllers]
91
+ rails g paloma:add [controller]
88
92
  ```
89
93
  **Example:**
90
94
  ```
@@ -98,7 +102,7 @@ rails g paloma:add [controllers]
98
102
 
99
103
  2. Generate a callback file for a controller's action:
100
104
  ```
101
- rails g paloma:add [controllers] [action]
105
+ rails g paloma:add [controller] [action]
102
106
  ```
103
107
  **Example:**
104
108
  ```
@@ -113,7 +117,7 @@ rails g paloma:add [controllers] [action]
113
117
 
114
118
  3. Generate multiple callback files:
115
119
  ```
116
- rails g paloma:add [controllers] [action_1] [action_2] ... [action_n]
120
+ rails g paloma:add [controller] [action_1] [action_2] ... [action_n]
117
121
  ```
118
122
  **Example:**
119
123
  ```
@@ -130,7 +134,7 @@ rails g paloma:add [controllers] [action_1] [action_2] ... [action_n]
130
134
 
131
135
  4. Generate namespaced controller and callbacks:
132
136
  ```
133
- rails g paloma:add [namespace]/[controllers] [action_1] [action_2] ... [action_n]
137
+ rails g paloma:add [namespace]/[controller] [action_1] [action_2] ... [action_n]
134
138
  ```
135
139
 
136
140
  **Example:**
@@ -144,17 +148,19 @@ rails g paloma:add [namespace]/[controllers] [action_1] [action_2] ... [action_n
144
148
  * /users
145
149
  * new.js
146
150
 
147
- **Note:** You can directly run `rails g paloma:add [controllers] [action]` or `rails g paloma:add [namespace]/[controllers] [action]` even the controller folder is not yet
151
+ **Notes:**
152
+
153
+ * You can directly run `rails g paloma:add [controller] [action]` or `rails g paloma:add [namespace]/[controller] [action]` even the controller folder is not yet
148
154
  existing on `paloma` folder. It will be created automatically.
149
155
 
156
+ * Controller folder and action javascript files will automatically be created after running `rails g controller` or `rails g scaffold`.
150
157
 
151
158
  Advanced Callbacks
152
159
  -
153
- By default Paloma will execute the callback that matches the response's current controller and action if it finds one.
154
- For instance if the current response is from the `new` action of the `Users` controller, then Paloma will execute the callback
155
- named `users/new`.
160
+ By default Paloma will execute the callback that matches the current controller and action if it finds one.
161
+ For instance, if the current response is from the `new` action of the `Users` controller, then Paloma will try to execute `callbacks['users']['new']` if it exists.
156
162
 
157
- You can manipulate callback behavior by using the `js_callback` command before the `render` or `redirect_to` command in your controllers.
163
+ You can manipulate callback behavior by using the `js` command before the `render` or `redirect_to` command in your controllers.
158
164
 
159
165
  1. Preventing the Callback to execute.
160
166
 
@@ -163,33 +169,33 @@ You can manipulate callback behavior by using the `js_callback` command before t
163
169
  user = User.find params[:id]
164
170
  user.destroy
165
171
 
166
- js_callback false
172
+ js false
167
173
  end
168
174
  ```
169
175
 
170
- `[controllers]/destroy` callback will not be executed.
176
+ `callbacks["controller"]["destroy"]` will not be executed.
171
177
 
172
178
  2. Using other action's callback from the same controller.
173
179
 
174
180
  ```ruby
175
181
  def edit
176
182
  @user = User.find params[:id]
177
- js_callback :new
183
+ js :new
178
184
  end
179
185
  ```
180
186
 
181
- This will execute `[controllers]/new` callback instead of `[controllers]/edit`.
187
+ This will execute `callback["controllers"]["new"]` instead of `callback["controllers"]["edit"]`.
182
188
 
183
189
  3. Using other action's callback from other controller.
184
190
 
185
191
  ```ruby
186
192
  def index
187
193
  @users = User.all
188
- js_callback :controller => 'clients', :action => 'index'
194
+ js :controller => 'clients', :action => 'index'
189
195
  end
190
196
  ```
191
197
 
192
- This will execute `clients/index` callback instead of `[controllers]/index`.
198
+ This will execute `callbacks["clients"]["index"]` instead of `callbacks["controllers"]["index"]`.
193
199
 
194
200
 
195
201
  4. Using other action's callback from a namespaced controller.
@@ -200,17 +206,17 @@ You can manipulate callback behavior by using the `js_callback` command before t
200
206
  @user = User.find params[:id]
201
207
  @user.destroy
202
208
 
203
- js_callback :controller => 'admin/users', :action => :destroy
209
+ js :controller => 'admin/users', :action => :destroy
204
210
  end
205
211
  end
206
212
  ```
207
213
 
208
- This will execute `admin/users/destroy` callback instead of `users/destroy`.
214
+ This will execute `callbacks["admin/users"]["destroy"]` instead of `callbacks["users"]["destroy"]`.
209
215
 
210
216
 
211
217
  Passing Parameters
212
218
  -
213
- You can also pass parameters to the callback by passing a `:params` key to `js_callback`. The passed parameters
219
+ You can also pass parameters to the callback by passing a `:params` key to `js`. The passed parameters
214
220
  will be available on the callback by the `params` object.
215
221
 
216
222
  **Example:**
@@ -221,69 +227,202 @@ def destroy
221
227
  user = User.find params[:id]
222
228
  user.destroy
223
229
 
224
- js_callback :params => {:user_id => params[:id]}
230
+ js :params => {:user_id => params[:id]}
225
231
  end
226
232
  ```
227
233
 
228
234
  `/paloma/users/destroy.js`
229
235
  ```javascript
230
- Paloma.callbacks['users/destroy'] = function(params){
236
+ Paloma.callbacks['users']['destroy'] = function(params){
231
237
  var id = params['user_id'];
232
238
  alert('User ' + id + ' deleted.');
233
239
  };
234
240
  ```
235
241
 
236
- Callback Helpers
237
- -
238
- Callback helpers are inside Paloma objects in order to prevent conflicts from different functions and variables.
242
+ ## Filters
243
+
244
+ This is almost similar to Rails controller filters. These are functions executed either `before`, `after`,
245
+ or even `around` (before and after) a Paloma callback is executed.
246
+
247
+ Filters are defined on `_filters.js` files in Paloma's root folder, namespace folder, or controller folder.
248
+
249
+ ### Syntax
250
+
251
+ ```javascript
252
+ filter.as('filter name').before_all().perform(function(params){
253
+ alert("I'm a before filter!");
254
+ });
255
+
256
+ filter.as('another filter').after_all().perform(function(params{
257
+ alert("I'm an after filter");
258
+ });
259
+ ```
239
260
 
240
- 1. Global
261
+ ### Specify Actions To Filter
241
262
 
242
- Helper functions and variables can be defined in `paloma/paloma.js` inside the `Paloma.g` object.
263
+ 1. For all actions.
243
264
 
244
- **Example:**
245
265
  ```javascript
246
- Paloma.g = {
247
- helper: function(){
248
- // do something sexy
249
- },
250
-
251
- helper_variable: 1000
252
- };
266
+ filter.as('name').before_all()
267
+ filter.as('name').after_all()
268
+ filter.as('name').around_all()
253
269
  ```
254
270
 
255
- 3. Namespace's Scope
256
-
257
- Helper functions and variables that is shared inside a namespace can be defined in `paloma/[namespace]/_local.js` inside
258
- the `Paloma.[namespace]` object.
271
+ 2. Only for specific action/s.
259
272
 
260
- **Example:**
261
273
  ```javascript
262
- Paloma.admin = {
263
- namespaced_helper: function(){
264
- // do something sexy
265
- },
266
-
267
- helper_variable: 1
268
- };
274
+ filter.as('name').before('new', 'edit', 'update')
275
+ filter.as('name').after('destroy')
276
+ filter.as('name').around('show')
269
277
  ```
270
278
 
271
- 2. Controller's Scope
272
-
273
- Helper functions that you will only use for a certain controller can be defined in `paloma/[controllers]/_local.js` inside
274
- the `Paloma.[controllers]` object.
279
+ 3. Except for specific action/s.
275
280
 
276
- **Example:**
277
281
  ```javascript
278
- Paloma.users = {
279
- local_helper: function(){
280
- // do something sexy
281
- },
282
-
283
- helper_variable: 1
284
- };
282
+ filter.as('name').except_before('new')
283
+ filter.as('name').except_after('destroy', 'edit')
284
+ filter.as('name').except_around('show')
285
285
  ```
286
+
287
+ ### Filter Inheritance
288
+
289
+ All `_filters.js` inherit filters defined on the global `_filters.js` file.
290
+ Controller's `_filters.js` will also inherit filters defined on its namespace `_filters.js` if it exists.
291
+
292
+
293
+ ### Execution Time
294
+
295
+ Global filters (on `/paloma/_filters.js`) are executed first, then Namespace filters if any,
296
+ then Controller filters.
297
+
298
+ Before filters, as you've guessed, are executed before the callback is called.
299
+ The order of execution is based on the order of declaration.
300
+ After before filters, around filters are executed then the callback is finally executed.
301
+ After filters are called after the callback is executed, then it will execute the around filters again.
302
+
303
+ ### Shared Variable Between Filter and Callback
304
+
305
+ Automatically, filters has an access to the `params` object passed via the `js` ruby method.
306
+ But you can also make a variable visible both on a filter and a callback using the `_x` object.
307
+
308
+ **Example:**
309
+
310
+ on `_filters.js`:
311
+
312
+ ```javascript
313
+ filter.as('filter name').before('new').perform(function(params){
314
+ _x.sharedVariable = "Sexy Paloma";
315
+ });
316
+ ```
317
+
318
+ on `new.js`:
319
+
320
+ ```javascript
321
+ Paloma.callbacks['controller']['new'] = function(params){
322
+ alert(_x.sharedVariable); // outputs "Sexy Paloma";
323
+ });
324
+ ```
325
+
326
+ ##Locals
327
+
328
+ Locals are variables or methods which can be made locally available within a controller or a namespace. Locals can also be made available throughout the whole Paloma files (globally).
329
+
330
+ The motivation of Locals is to organize helper methods and helper variables within a namespace or controller.
331
+
332
+ 1. **Application-wide Locals**
333
+
334
+ Defined on `paloma/_locals.js`.
335
+ This contains methods and variables that are intended to be available globally.
336
+
337
+
338
+ 2. **Namespace-wide Locals**
339
+
340
+ Defiend on `paloma/namespace/_locals.js`.
341
+ This contains methods and variables that are intended to be available on the specific namespace only.
342
+
343
+
344
+ 3. **Controller-wide Locals**
345
+
346
+ Defined on `paloma/controller/_locals.js` or `paloma/namespace/controller/_locals.js`.
347
+ This contains methods and variables that are intended to be available on the specific controller only.
348
+
349
+
350
+ ###Creating Locals
351
+ Locals can be created using the `locals` object inside `_filters.js` file.
352
+
353
+ **Example:**
354
+
355
+ ```javascript
356
+ locals.helperMethod = function(){
357
+ return "Hello World";
358
+ };
359
+
360
+ locals.helperVariable = "WOW!";
361
+ ```
362
+
363
+ ###Accessing Locals
364
+ Locals can be accessed in your filter and callback files using the `_l` object.
365
+
366
+ **Example**
367
+
368
+ ```javascript
369
+ Paloma.callbacks['users']['new'] = function(params){
370
+ alert("Hello Sexy User");
286
371
 
372
+ _l.helperMethod();
373
+
374
+ console.log(_l.helperVariable);
375
+ };
376
+ ```
377
+
378
+ ###Accessing Locals From Other Controller/Namespace
379
+ Sometimes there is a need to use other's local methods and variables.
380
+ You can achieve this by using the `Paloma.locals` object or its alias `_L`.
381
+
382
+ **Example**
383
+ ```javascript
384
+ Paloma.callbacks['users']['new'] = function(params){
385
+ _L.otherController.helperMethod(); // accessing local helperMethod() of the otherController
386
+ _L['otherController'].helperVariable;
387
+ }
388
+ ```
389
+
390
+
391
+ ###Locals Inheritance
392
+ `_locals.js` inherits locals from its parent `_locals.js`, either from namespace or application-wide.
393
+ You can also override locals inherited from parents.
394
+
395
+ **Example**
396
+
397
+ `paloma/_locals.js` contains:
398
+ ```javascript
399
+ locals.globalMethod = function(){ console.log("I'm from Global"); }
400
+ ```
401
+
402
+ `paloma/namespace/_locals.js` contains:
403
+ ```javascript
404
+ locals.namespaceMethod = function(){ console.log("I'm from Namespace"); }
405
+ locals.anotherNamespaceMethod = function(){ console.log("I'm also from Namespace"); }
406
+ ```
407
+
408
+ `paloma/namespace/controller/_locals.js` contains:
409
+ ```javascript
410
+ locals.controllerMethod = function(){ console.log("I'm from Controller"); }
411
+ locals.anotherNamespacedMethod = function(){ console.log("Override!"); }; // Overrides namespace local
412
+ ```
413
+
414
+ Since `controller` is under the global `_local.js` and namespace `_local.js` it automatically inherits all their locals.
415
+ So you can do something like this inside the controller callback files (or filter files):
416
+
417
+ ```javascript
418
+ Paloma.callbacks['namespace/controller']['action'] = function(params){
419
+ _l.controllerMethod(); // outputs "I'm from Controller"
420
+ _l.namespacedMethod(); // outputs "I'm from Namespace"
421
+ _l.globalMethod(); // outputs "I'm from Global"
422
+ _l.anotherNamespacedMethod(); // outputs "Override!"
423
+ };
424
+ ```
425
+
287
426
  Callback Chains
288
427
  -
289
428
  Callback chains are created after a redirect action. The chain will continue to increase its length until a render action is detected.
@@ -0,0 +1,14 @@
1
+ (function(){
2
+ // Initializes the main container for all filters and skippers for this
3
+ // specific scope.
4
+ var filter = new Paloma.FilterScope(':scope');
5
+
6
+ // The _x object is also available on callbacks.
7
+ // You can make a variable visible on callbacks by using _x here.
8
+ //
9
+ // Example:
10
+ // _x.visibleOnCallback = "I'm a shared variable"
11
+ var _x = Paloma.variableContainer;
12
+
13
+ // ~> Start definitions here and remove this line.
14
+ })();