public
Fork of rails/rails
Description: Ruby on Rails - forked for implementing I18n patch
Homepage: http://rubyonrails.org
Clone URL: git://github.com/svenfuchs/rails.git
Get buffer for fragment cache from template's @output_buffer
josh (author)
Tue Jul 15 12:41:38 -0700 2008
commit  aca246ab25497bb6787d2e18680e9f73ad13d223
tree    ad107ae39feb55960a4f6faf084b3ad8bc56cbec
parent  4f72feb84c25b54f66c7192c788b7fd965f2d493
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *Edge*
0
 
0
+* Get buffer for fragment cache from template's @output_buffer [Josh Peek]
0
+
0
 * Set config.action_view.warn_cache_misses = true to receive a warning if you perform an action that results in an expensive disk operation that could be cached [Josh Peek]
0
 
0
 * Refactor template preloading. New abstractions include Renderable mixins and a refactored Template class [Josh Peek]
...
60
61
62
63
 
64
65
66
67
68
69
...
60
61
62
 
63
64
 
 
65
66
67
0
@@ -60,10 +60,8 @@ module ActionController #:nodoc:
0
         ActiveSupport::Cache.expand_cache_key(key.is_a?(Hash) ? url_for(key).split("://").last : key, :views)
0
       end
0
 
0
- def fragment_for(block, name = {}, options = nil) #:nodoc:
0
+ def fragment_for(buffer, name = {}, options = nil, &block) #:nodoc:
0
         if perform_caching
0
- buffer = yield
0
-
0
           if cache = read_fragment(name, options)
0
             buffer.concat(cache)
0
           else
...
32
33
34
35
 
36
37
38
...
32
33
34
 
35
36
37
38
0
@@ -32,7 +32,7 @@ module ActionView
0
       # <i>Topics listed alphabetically</i>
0
       # <% end %>
0
       def cache(name = {}, options = nil, &block)
0
- _last_render.handler.new(@controller).cache_fragment(block, name, options)
0
+ @controller.fragment_for(output_buffer, name, options, &block)
0
       end
0
     end
0
   end
...
3
4
5
6
 
7
8
 
9
10
11
12
13
 
 
 
 
14
15
16
17
18
19
20
 
 
21
22
23
24
 
25
26
27
...
29
30
31
32
 
33
34
35
...
50
51
52
53
54
 
 
55
56
57
...
63
64
65
66
 
67
68
69
...
74
75
76
77
78
 
 
79
80
81
...
93
94
95
96
 
97
98
99
...
103
104
105
106
 
107
108
109
...
114
115
116
117
118
 
 
119
120
 
121
122
 
123
124
125
 
126
127
 
128
129
130
 
131
132
 
133
134
 
135
136
137
 
138
139
140
 
 
141
142
143
 
144
145
146
147
 
148
149
150
151
152
153
154
 
 
155
156
157
158
159
160
161
 
162
163
164
165
166
167
168
 
 
 
 
169
170
171
172
173
174
 
175
176
177
...
180
181
182
183
 
184
185
186
187
188
 
 
189
190
191
192
193
194
195
196
 
 
197
198
199
 
 
200
201
202
203
204
 
 
205
206
207
208
209
210
211
 
212
213
214
215
 
216
217
218
219
 
220
221
222
...
228
229
230
231
 
232
233
234
...
238
239
240
241
 
242
243
244
 
245
246
247
...
251
252
253
254
 
255
256
257
...
262
263
264
265
266
 
 
267
268
269
270
271
272
273
 
274
275
276
...
286
287
288
289
290
 
 
291
292
293
 
294
295
296
...
299
300
301
302
 
303
304
 
305
306
307
308
309
310
 
311
312
313
314
315
316
 
 
317
318
319
...
323
324
325
326
327
 
 
328
329
330
331
332
333
334
 
 
335
336
 
337
338
 
339
340
341
...
348
349
350
351
 
352
353
354
...
387
388
389
390
 
391
392
393
 
394
395
396
397
398
 
 
 
399
400
401
402
403
404
405
406
 
 
407
408
409
...
423
424
425
426
 
427
428
429
...
433
434
435
436
 
437
438
 
439
440
 
441
442
443
...
455
456
457
458
 
459
460
461
...
476
477
478
479
 
480
481
 
482
483
484
...
500
501
502
503
 
504
505
506
507
508
509
510
 
511
512
513
...
518
519
520
521
 
522
523
524
...
544
545
546
547
 
548
549
550
...
558
559
560
561
 
562
563
564
...
574
575
576
577
578
 
 
579
580
581
582
 
583
584
585
586
 
587
588
589
...
591
592
593
594
595
596
 
 
 
597
598
599
600
601
602
603
604
 
 
 
 
 
605
606
607
...
614
615
616
617
 
618
619
620
 
621
622
 
623
624
625
...
655
656
657
658
 
659
660
661
...
668
669
670
671
 
672
673
674
...
689
690
691
692
693
 
 
694
695
696
697
698
 
699
700
701
702
703
704
705
 
706
707
 
708
709
710
711
 
712
713
 
714
715
716
 
717
718
719
...
721
722
723
724
 
725
726
727
 
728
729
730
 
 
731
732
733
...
750
751
752
753
 
754
755
756
...
764
765
766
767
 
768
769
770
...
786
787
788
789
 
790
791
792
...
798
799
800
801
 
802
803
804
...
810
811
812
813
 
814
815
 
816
817
818
...
822
823
824
825
 
826
827
828
...
832
833
834
835
 
836
837
 
838
839
840
...
844
845
846
847
 
848
849
 
850
851
852
...
856
857
858
859
 
860
861
862
863
864
865
866
 
867
868
869
870
871
872
873
 
874
875
876
...
884
885
886
887
 
888
889
 
890
891
892
893
894
 
895
896
897
 
898
899
900
...
907
908
909
910
 
911
912
913
...
918
919
920
921
 
922
923
924
925
926
927
 
928
929
930
...
933
934
935
936
 
937
938
939
 
940
941
942
...
949
950
951
952
953
 
 
954
955
956
957
958
 
959
960
961
...
963
964
965
966
 
967
968
969
970
971
972
 
973
974
975
976
977
978
 
979
980
981
982
 
 
983
984
985
 
986
987
988
989
 
990
991
992
993
994
995
 
996
997
998
999
1000
 
 
1001
1002
1003
1004
1005
 
1006
1007
1008
1009
 
1010
1011
1012
1013
1014
 
1015
1016
1017
1018
 
1019
1020
1021
1022
1023
1024
1025
 
1026
1027
1028
...
1035
1036
1037
1038
 
1039
1040
1041
1042
1043
1044
 
1045
1046
1047
...
1049
1050
1051
1052
 
1053
1054
1055
...
1062
1063
1064
1065
 
1066
1067
1068
...
1071
1072
1073
1074
 
1075
1076
1077
1078
 
1079
1080
1081
 
1082
1083
1084
...
1095
1096
1097
1098
 
1099
1100
1101
...
1108
1109
1110
1111
 
1112
1113
1114
...
1124
1125
1126
1127
 
1128
1129
1130
...
1133
1134
1135
1136
 
1137
1138
1139
1140
 
1141
1142
1143
1144
1145
1146
 
1147
1148
1149
1150
1151
1152
 
1153
1154
1155
...
1160
1161
1162
1163
 
1164
1165
1166
1167
 
1168
1169
1170
...
1172
1173
1174
1175
 
1176
1177
1178
1179
 
1180
1181
1182
...
1195
1196
1197
1198
 
1199
1200
1201
...
1213
1214
1215
1216
 
1217
1218
1219
...
1222
1223
1224
1225
 
1226
1227
1228
1229
 
1230
1231
1232
1233
1234
1235
1236
 
 
1237
1238
1239
...
1295
1296
1297
1298
 
1299
1300
1301
1302
1303
1304
 
1305
1306
1307
...
3
4
5
 
6
7
 
8
9
 
 
 
 
10
11
12
13
14
15
16
17
18
 
 
19
20
21
22
23
 
24
25
26
27
...
29
30
31
 
32
33
34
35
...
50
51
52
 
 
53
54
55
56
57
...
63
64
65
 
66
67
68
69
...
74
75
76
 
 
77
78
79
80
81
...
93
94
95
 
96
97
98
99
...
103
104
105
 
106
107
108
109
...
114
115
116
 
 
117
118
119
 
120
121
 
122
123
124
 
125
126
 
127
128
129
 
130
131
 
132
133
 
134
135
136
 
137
138
 
 
139
140
141
142
 
143
144
145
146
 
147
148
149
150
151
152
 
 
153
154
155
156
157
158
159
160
 
161
162
163
164
 
 
 
 
165
166
167
168
169
170
171
172
173
 
174
175
176
177
...
180
181
182
 
183
184
185
186
 
 
187
188
189
190
191
192
193
194
 
 
195
196
197
 
 
198
199
200
201
202
 
 
203
204
205
206
207
208
209
210
 
211
212
213
214
 
215
216
217
218
 
219
220
221
222
...
228
229
230
 
231
232
233
234
...
238
239
240
 
241
242
243
 
244
245
246
247
...
251
252
253
 
254
255
256
257
...
262
263
264
 
 
265
266
267
268
269
270
271
272
 
273
274
275
276
...
286
287
288
 
 
289
290
291
292
 
293
294
295
296
...
299
300
301
 
302
303
 
304
305
306
307
308
309
 
310
311
312
313
314
 
 
315
316
317
318
319
...
323
324
325
 
 
326
327
328
329
330
331
332
 
 
333
334
335
 
336
337
 
338
339
340
341
...
348
349
350
 
351
352
353
354
...
387
388
389
 
390
391
392
 
393
394
395
 
 
 
396
397
398
399
400
401
402
403
404
 
 
405
406
407
408
409
...
423
424
425
 
426
427
428
429
...
433
434
435
 
436
437
 
438
439
 
440
441
442
443
...
455
456
457
 
458
459
460
461
...
476
477
478
 
479
480
 
481
482
483
484
...
500
501
502
 
503
504
505
506
507
508
509
 
510
511
512
513
...
518
519
520
 
521
522
523
524
...
544
545
546
 
547
548
549
550
...
558
559
560
 
561
562
563
564
...
574
575
576
 
 
577
578
579
580
581
582
583
584
585
586
 
587
588
589
590
...
592
593
594
 
 
 
595
596
597
598
599
600
 
 
 
 
 
601
602
603
604
605
606
607
608
...
615
616
617
 
618
619
620
 
621
622
 
623
624
625
626
...
656
657
658
 
659
660
661
662
...
669
670
671
 
672
673
674
675
...
690
691
692
 
 
693
694
695
696
697
698
 
699
700
701
702
703
704
705
 
706
707
 
708
709
710
711
 
712
713
 
714
715
716
 
717
718
719
720
...
722
723
724
 
725
726
727
 
728
729
 
 
730
731
732
733
734
...
751
752
753
 
754
755
756
757
...
765
766
767
 
768
769
770
771
...
787
788
789
 
790
791
792
793
...
799
800
801
 
802
803
804
805
...
811
812
813
 
814
815
 
816
817
818
819
...
823
824
825
 
826
827
828
829
...
833
834
835
 
836
837
 
838
839
840
841
...
845
846
847
 
848
849
 
850
851
852
853
...
857
858
859
 
860
861
862
863
864
865
866
 
867
868
869
870
871
872
873
 
874
875
876
877
...
885
886
887
 
888
889
 
890
891
892
893
894
 
895
896
897
 
898
899
900
901
...
908
909
910
 
911
912
913
914
...
919
920
921
 
922
923
924
925
926
927
 
928
929
930
931
...
934
935
936
 
937
938
939
 
940
941
942
943
...
950
951
952
 
 
953
954
955
956
957
958
 
959
960
961
962
...
964
965
966
 
967
968
969
970
971
972
 
973
974
975
976
977
978
 
979
980
981
 
 
982
983
984
985
 
986
987
988
989
 
990
991
992
993
994
995
 
996
997
998
999
 
 
1000
1001
1002
1003
1004
1005
 
1006
1007
1008
1009
 
1010
1011
1012
1013
1014
 
1015
1016
1017
1018
 
1019
1020
1021
1022
1023
1024
1025
 
1026
1027
1028
1029
...
1036
1037
1038
 
1039
1040
1041
1042
1043
1044
 
1045
1046
1047
1048
...
1050
1051
1052
 
1053
1054
1055
1056
...
1063
1064
1065
 
1066
1067
1068
1069
...
1072
1073
1074
 
1075
1076
1077
1078
 
1079
1080
1081
 
1082
1083
1084
1085
...
1096
1097
1098
 
1099
1100
1101
1102
...
1109
1110
1111
 
1112
1113
1114
1115
...
1125
1126
1127
 
1128
1129
1130
1131
...
1134
1135
1136
 
1137
1138
1139
1140
 
1141
1142
1143
1144
1145
1146
 
1147
1148
1149
1150
1151
1152
 
1153
1154
1155
1156
...
1161
1162
1163
 
1164
1165
1166
1167
 
1168
1169
1170
1171
...
1173
1174
1175
 
1176
1177
1178
1179
 
1180
1181
1182
1183
...
1196
1197
1198
 
1199
1200
1201
1202
...
1214
1215
1216
 
1217
1218
1219
1220
...
1223
1224
1225
 
1226
1227
1228
1229
 
1230
1231
1232
1233
1234
1235
 
 
1236
1237
1238
1239
1240
...
1296
1297
1298
 
1299
1300
1301
1302
1303
1304
 
1305
1306
1307
1308
0
@@ -3,25 +3,25 @@ require 'set'
0
 module ActionView
0
   module Helpers
0
     # Prototype[http://www.prototypejs.org/] is a JavaScript library that provides
0
- # DOM[http://en.wikipedia.org/wiki/Document_Object_Model] manipulation,
0
+ # DOM[http://en.wikipedia.org/wiki/Document_Object_Model] manipulation,
0
     # Ajax[http://www.adaptivepath.com/publications/essays/archives/000385.php]
0
- # functionality, and more traditional object-oriented facilities for JavaScript.
0
+ # functionality, and more traditional object-oriented facilities for JavaScript.
0
     # This module provides a set of helpers to make it more convenient to call
0
- # functions from Prototype using Rails, including functionality to call remote
0
- # Rails methods (that is, making a background request to a Rails action) using Ajax.
0
- # This means that you can call actions in your controllers without
0
- # reloading the page, but still update certain parts of it using
0
+ # functions from Prototype using Rails, including functionality to call remote
0
+ # Rails methods (that is, making a background request to a Rails action) using Ajax.
0
+ # This means that you can call actions in your controllers without
0
+ # reloading the page, but still update certain parts of it using
0
     # injections into the DOM. A common use case is having a form that adds
0
     # a new element to a list without reloading the page or updating a shopping
0
     # cart total when a new item is added.
0
     #
0
     # == Usage
0
- # To be able to use these helpers, you must first include the Prototype
0
- # JavaScript framework in your pages.
0
+ # To be able to use these helpers, you must first include the Prototype
0
+ # JavaScript framework in your pages.
0
     #
0
     # javascript_include_tag 'prototype'
0
     #
0
- # (See the documentation for
0
+ # (See the documentation for
0
     # ActionView::Helpers::JavaScriptHelper for more information on including
0
     # this and other JavaScript files in your Rails templates.)
0
     #
0
@@ -29,7 +29,7 @@ module ActionView
0
     #
0
     # link_to_remote "Add to cart",
0
     # :url => { :action => "add", :id => product.id },
0
- # :update => { :success => "cart", :failure => "error" }
0
+ # :update => { :success => "cart", :failure => "error" }
0
     #
0
     # ...through a form...
0
     #
0
@@ -50,8 +50,8 @@ module ActionView
0
     # :update => :hits,
0
     # :with => 'query'
0
     # %>
0
- #
0
- # As you can see, there are numerous ways to use Prototype's Ajax functions (and actually more than
0
+ #
0
+ # As you can see, there are numerous ways to use Prototype's Ajax functions (and actually more than
0
     # are listed here); check out the documentation for each method to find out more about its usage and options.
0
     #
0
     # === Common Options
0
@@ -63,7 +63,7 @@ module ActionView
0
     # When building your action handlers (that is, the Rails actions that receive your background requests), it's
0
     # important to remember a few things. First, whatever your action would normall return to the browser, it will
0
     # return to the Ajax call. As such, you typically don't want to render with a layout. This call will cause
0
- # the layout to be transmitted back to your page, and, if you have a full HTML/CSS, will likely mess a lot of things up.
0
+ # the layout to be transmitted back to your page, and, if you have a full HTML/CSS, will likely mess a lot of things up.
0
     # You can turn the layout off on particular actions by doing the following:
0
     #
0
     # class SiteController < ActionController::Base
0
@@ -74,8 +74,8 @@ module ActionView
0
     #
0
     # render :layout => false
0
     #
0
- # You can tell the type of request from within your action using the <tt>request.xhr?</tt> (XmlHttpRequest, the
0
- # method that Ajax uses to make background requests) method.
0
+ # You can tell the type of request from within your action using the <tt>request.xhr?</tt> (XmlHttpRequest, the
0
+ # method that Ajax uses to make background requests) method.
0
     # def name
0
     # # Is this an XmlHttpRequest request?
0
     # if (request.xhr?)
0
@@ -93,7 +93,7 @@ module ActionView
0
     #
0
     # Dropping this in your ApplicationController turns the layout off for every request that is an "xhr" request.
0
     #
0
- # If you are just returning a little data or don't want to build a template for your output, you may opt to simply
0
+ # If you are just returning a little data or don't want to build a template for your output, you may opt to simply
0
     # render text output, like this:
0
     #
0
     # render :text => 'Return this from my method!'
0
@@ -103,7 +103,7 @@ module ActionView
0
     #
0
     # == Updating multiple elements
0
     # See JavaScriptGenerator for information on updating multiple elements
0
- # on the page in an Ajax response.
0
+ # on the page in an Ajax response.
0
     module PrototypeHelper
0
       unless const_defined? :CALLBACKS
0
         CALLBACKS = Set.new([ :uninitialized, :loading, :loaded,
0
@@ -114,64 +114,64 @@ module ActionView
0
                          :form, :with, :update, :script ]).merge(CALLBACKS)
0
       end
0
 
0
- # Returns a link to a remote action defined by <tt>options[:url]</tt>
0
- # (using the url_for format) that's called in the background using
0
+ # Returns a link to a remote action defined by <tt>options[:url]</tt>
0
+ # (using the url_for format) that's called in the background using
0
       # XMLHttpRequest. The result of that request can then be inserted into a
0
- # DOM object whose id can be specified with <tt>options[:update]</tt>.
0
+ # DOM object whose id can be specified with <tt>options[:update]</tt>.
0
       # Usually, the result would be a partial prepared by the controller with
0
- # render :partial.
0
+ # render :partial.
0
       #
0
       # Examples:
0
- # # Generates: <a href="#" onclick="new Ajax.Updater('posts', '/blog/destroy/3', {asynchronous:true, evalScripts:true});
0
+ # # Generates: <a href="#" onclick="new Ajax.Updater('posts', '/blog/destroy/3', {asynchronous:true, evalScripts:true});
0
       # # return false;">Delete this post</a>
0
- # link_to_remote "Delete this post", :update => "posts",
0
+ # link_to_remote "Delete this post", :update => "posts",
0
       # :url => { :action => "destroy", :id => post.id }
0
       #
0
- # # Generates: <a href="#" onclick="new Ajax.Updater('emails', '/mail/list_emails', {asynchronous:true, evalScripts:true});
0
+ # # Generates: <a href="#" onclick="new Ajax.Updater('emails', '/mail/list_emails', {asynchronous:true, evalScripts:true});
0
       # # return false;"><img alt="Refresh" src="/images/refresh.png?" /></a>
0
- # link_to_remote(image_tag("refresh"), :update => "emails",
0
+ # link_to_remote(image_tag("refresh"), :update => "emails",
0
       # :url => { :action => "list_emails" })
0
- #
0
+ #
0
       # You can override the generated HTML options by specifying a hash in
0
       # <tt>options[:html]</tt>.
0
- #
0
+ #
0
       # link_to_remote "Delete this post", :update => "posts",
0
- # :url => post_url(@post), :method => :delete,
0
- # :html => { :class => "destructive" }
0
+ # :url => post_url(@post), :method => :delete,
0
+ # :html => { :class => "destructive" }
0
       #
0
       # You can also specify a hash for <tt>options[:update]</tt> to allow for
0
- # easy redirection of output to an other DOM element if a server-side
0
+ # easy redirection of output to an other DOM element if a server-side
0
       # error occurs:
0
       #
0
       # Example:
0
- # # Generates: <a href="#" onclick="new Ajax.Updater({success:'posts',failure:'error'}, '/blog/destroy/5',
0
+ # # Generates: <a href="#" onclick="new Ajax.Updater({success:'posts',failure:'error'}, '/blog/destroy/5',
0
       # # {asynchronous:true, evalScripts:true}); return false;">Delete this post</a>
0
       # link_to_remote "Delete this post",
0
       # :url => { :action => "destroy", :id => post.id },
0
       # :update => { :success => "posts", :failure => "error" }
0
       #
0
- # Optionally, you can use the <tt>options[:position]</tt> parameter to
0
- # influence how the target DOM element is updated. It must be one of
0
+ # Optionally, you can use the <tt>options[:position]</tt> parameter to
0
+ # influence how the target DOM element is updated. It must be one of
0
       # <tt>:before</tt>, <tt>:top</tt>, <tt>:bottom</tt>, or <tt>:after</tt>.
0
       #
0
       # The method used is by default POST. You can also specify GET or you
0
       # can simulate PUT or DELETE over POST. All specified with <tt>options[:method]</tt>
0
       #
0
       # Example:
0
- # # Generates: <a href="#" onclick="new Ajax.Request('/person/4', {asynchronous:true, evalScripts:true, method:'delete'});
0
+ # # Generates: <a href="#" onclick="new Ajax.Request('/person/4', {asynchronous:true, evalScripts:true, method:'delete'});
0
       # # return false;">Destroy</a>
0
       # link_to_remote "Destroy", :url => person_url(:id => person), :method => :delete
0
       #
0
- # By default, these remote requests are processed asynchronous during
0
- # which various JavaScript callbacks can be triggered (for progress
0
- # indicators and the likes). All callbacks get access to the
0
- # <tt>request</tt> object, which holds the underlying XMLHttpRequest.
0
+ # By default, these remote requests are processed asynchronous during
0
+ # which various JavaScript callbacks can be triggered (for progress
0
+ # indicators and the likes). All callbacks get access to the
0
+ # <tt>request</tt> object, which holds the underlying XMLHttpRequest.
0
       #
0
       # To access the server response, use <tt>request.responseText</tt>, to
0
       # find out the HTTP status, use <tt>request.status</tt>.
0
       #
0
       # Example:
0
- # # Generates: <a href="#" onclick="new Ajax.Request('/words/undo?n=33', {asynchronous:true, evalScripts:true,
0
+ # # Generates: <a href="#" onclick="new Ajax.Request('/words/undo?n=33', {asynchronous:true, evalScripts:true,
0
       # # onComplete:function(request){undoRequestCompleted(request)}}); return false;">hello</a>
0
       # word = 'hello'
0
       # link_to_remote word,
0
@@ -180,43 +180,43 @@ module ActionView
0
       #
0
       # The callbacks that may be specified are (in order):
0
       #
0
- # <tt>:loading</tt>:: Called when the remote document is being
0
+ # <tt>:loading</tt>:: Called when the remote document is being
0
&