actionpack 3.0.0.beta2 → 3.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionpack might be problematic. Click here for more details.
- data/CHANGELOG +37 -0
- data/lib/abstract_controller/rendering.rb +9 -11
- data/lib/action_controller.rb +0 -1
- data/lib/action_controller/base.rb +45 -44
- data/lib/action_controller/caching/pages.rb +2 -2
- data/lib/action_controller/deprecated/base.rb +21 -5
- data/lib/action_controller/metal/compatibility.rb +0 -2
- data/lib/action_controller/metal/cookies.rb +1 -1
- data/lib/action_controller/metal/helpers.rb +1 -1
- data/lib/action_controller/metal/http_authentication.rb +12 -5
- data/lib/action_controller/metal/responder.rb +3 -2
- data/lib/action_controller/polymorphic_routes.rb +1 -1
- data/lib/action_controller/railtie.rb +6 -1
- data/lib/action_controller/record_identifier.rb +2 -2
- data/lib/action_controller/test_case.rb +2 -0
- data/lib/action_dispatch/http/mime_negotiation.rb +2 -2
- data/lib/action_dispatch/http/request.rb +39 -21
- data/lib/action_dispatch/middleware/cookies.rb +18 -22
- data/lib/action_dispatch/middleware/params_parser.rb +8 -9
- data/lib/action_dispatch/middleware/session/cookie_store.rb +1 -1
- data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb +1 -1
- data/lib/action_dispatch/railtie.rb +1 -0
- data/lib/action_dispatch/routing.rb +24 -12
- data/lib/action_dispatch/routing/deprecated_mapper.rb +1 -1
- data/lib/action_dispatch/routing/mapper.rb +77 -51
- data/lib/action_dispatch/routing/route_set.rb +9 -5
- data/lib/action_dispatch/routing/url_for.rb +2 -3
- data/lib/action_dispatch/testing/integration.rb +24 -11
- data/lib/action_dispatch/testing/test_request.rb +2 -0
- data/lib/action_pack/version.rb +1 -1
- data/lib/action_view/base.rb +8 -2
- data/lib/action_view/helpers.rb +3 -6
- data/lib/action_view/helpers/active_model_helper.rb +20 -265
- data/lib/action_view/helpers/asset_tag_helper.rb +46 -9
- data/lib/action_view/helpers/atom_feed_helper.rb +2 -2
- data/lib/action_view/helpers/form_helper.rb +161 -120
- data/lib/action_view/helpers/form_options_helper.rb +0 -2
- data/lib/action_view/helpers/form_tag_helper.rb +76 -13
- data/lib/action_view/helpers/url_helper.rb +48 -21
- data/lib/action_view/locale/en.yml +0 -8
- data/lib/action_view/lookup_context.rb +11 -4
- data/lib/action_view/render/layouts.rb +32 -18
- data/lib/action_view/render/partials.rb +2 -2
- data/lib/action_view/template.rb +10 -1
- data/lib/action_view/test_case.rb +6 -1
- metadata +7 -8
- data/lib/action_controller/metal/verification.rb +0 -130
@@ -217,8 +217,6 @@ module ActionView
|
|
217
217
|
InstanceTag.new(object, method, self, options.delete(:object)).to_grouped_collection_select_tag(collection, group_method, group_label_method, option_key_method, option_value_method, options, html_options)
|
218
218
|
end
|
219
219
|
|
220
|
-
|
221
|
-
|
222
220
|
# Return select and option tags for the given object and method, using
|
223
221
|
# #time_zone_options_for_select to generate the list of option tags.
|
224
222
|
#
|
@@ -183,7 +183,7 @@ module ActionView
|
|
183
183
|
# Creates a file upload field. If you are using file uploads then you will also need
|
184
184
|
# to set the multipart option for the form tag:
|
185
185
|
#
|
186
|
-
#
|
186
|
+
# <%= form_tag '/upload', :multipart => true do %>
|
187
187
|
# <label for="file">File to Upload</label> <%= file_field_tag "file" %>
|
188
188
|
# <%= submit_tag %>
|
189
189
|
# <% end %>
|
@@ -199,8 +199,8 @@ module ActionView
|
|
199
199
|
# file_field_tag 'attachment'
|
200
200
|
# # => <input id="attachment" name="attachment" type="file" />
|
201
201
|
#
|
202
|
-
# file_field_tag 'avatar', :class => '
|
203
|
-
# # => <input class="
|
202
|
+
# file_field_tag 'avatar', :class => 'profile_input'
|
203
|
+
# # => <input class="profile_input" id="avatar" name="avatar" type="file" />
|
204
204
|
#
|
205
205
|
# file_field_tag 'picture', :disabled => true
|
206
206
|
# # => <input disabled="disabled" id="picture" name="picture" type="file" />
|
@@ -244,8 +244,8 @@ module ActionView
|
|
244
244
|
# password_field_tag 'confirm_pass', nil, :disabled => true
|
245
245
|
# # => <input disabled="disabled" id="confirm_pass" name="confirm_pass" type="password" />
|
246
246
|
#
|
247
|
-
# password_field_tag 'pin', '1234', :maxlength => 4, :size => 6, :class => "
|
248
|
-
# # => <input class="
|
247
|
+
# password_field_tag 'pin', '1234', :maxlength => 4, :size => 6, :class => "pin_input"
|
248
|
+
# # => <input class="pin_input" id="pin" maxlength="4" name="pin" size="6" type="password" value="1234" />
|
249
249
|
def password_field_tag(name = "password", value = nil, options = {})
|
250
250
|
text_field_tag(name, value, options.update("type" => "password"))
|
251
251
|
end
|
@@ -374,8 +374,8 @@ module ActionView
|
|
374
374
|
# submit_tag nil, :class => "form_submit"
|
375
375
|
# # => <input class="form_submit" name="commit" type="submit" />
|
376
376
|
#
|
377
|
-
# submit_tag "Edit", :disable_with => "Editing...", :class => "
|
378
|
-
# # => <input class="
|
377
|
+
# submit_tag "Edit", :disable_with => "Editing...", :class => "edit_button"
|
378
|
+
# # => <input class="edit_button" data-disable_with="Editing..."
|
379
379
|
# # name="commit" type="submit" value="Edit" />
|
380
380
|
#
|
381
381
|
# submit_tag "Save", :confirm => "Are you sure?"
|
@@ -386,7 +386,7 @@ module ActionView
|
|
386
386
|
options.stringify_keys!
|
387
387
|
|
388
388
|
if disable_with = options.delete("disable_with")
|
389
|
-
options["data-disable-with"] = disable_with
|
389
|
+
options["data-disable-with"] = disable_with
|
390
390
|
end
|
391
391
|
|
392
392
|
if confirm = options.delete("confirm")
|
@@ -398,7 +398,7 @@ module ActionView
|
|
398
398
|
|
399
399
|
# Displays an image which when clicked will submit the form.
|
400
400
|
#
|
401
|
-
# <tt>source</tt> is passed to AssetTagHelper#
|
401
|
+
# <tt>source</tt> is passed to AssetTagHelper#path_to_image
|
402
402
|
#
|
403
403
|
# ==== Options
|
404
404
|
# * <tt>:confirm => 'question?'</tt> - This will add a JavaScript confirm
|
@@ -414,11 +414,11 @@ module ActionView
|
|
414
414
|
# image_submit_tag("purchase.png", :disabled => true)
|
415
415
|
# # => <input disabled="disabled" src="/images/purchase.png" type="image" />
|
416
416
|
#
|
417
|
-
# image_submit_tag("search.png", :class => '
|
418
|
-
# # => <input class="
|
417
|
+
# image_submit_tag("search.png", :class => 'search_button')
|
418
|
+
# # => <input class="search_button" src="/images/search.png" type="image" />
|
419
419
|
#
|
420
|
-
# image_submit_tag("agree.png", :disabled => true, :class => "
|
421
|
-
# # => <input class="
|
420
|
+
# image_submit_tag("agree.png", :disabled => true, :class => "agree_disagree_button")
|
421
|
+
# # => <input class="agree_disagree_button" disabled="disabled" src="/images/agree.png" type="image" />
|
422
422
|
def image_submit_tag(source, options = {})
|
423
423
|
options.stringify_keys!
|
424
424
|
|
@@ -457,6 +457,69 @@ module ActionView
|
|
457
457
|
output.safe_concat("</fieldset>")
|
458
458
|
end
|
459
459
|
|
460
|
+
# Creates a text field of type "search".
|
461
|
+
#
|
462
|
+
# ==== Options
|
463
|
+
# * Accepts the same options as text_field_tag.
|
464
|
+
def search_field_tag(name, value = nil, options = {})
|
465
|
+
text_field_tag(name, value, options.stringify_keys.update("type" => "search"))
|
466
|
+
end
|
467
|
+
|
468
|
+
# Creates a text field of type "tel".
|
469
|
+
#
|
470
|
+
# ==== Options
|
471
|
+
# * Accepts the same options as text_field_tag.
|
472
|
+
def telephone_field_tag(name, value = nil, options = {})
|
473
|
+
text_field_tag(name, value, options.stringify_keys.update("type" => "tel"))
|
474
|
+
end
|
475
|
+
alias phone_field_tag telephone_field_tag
|
476
|
+
|
477
|
+
# Creates a text field of type "url".
|
478
|
+
#
|
479
|
+
# ==== Options
|
480
|
+
# * Accepts the same options as text_field_tag.
|
481
|
+
def url_field_tag(name, value = nil, options = {})
|
482
|
+
text_field_tag(name, value, options.stringify_keys.update("type" => "url"))
|
483
|
+
end
|
484
|
+
|
485
|
+
# Creates a text field of type "email".
|
486
|
+
#
|
487
|
+
# ==== Options
|
488
|
+
# * Accepts the same options as text_field_tag.
|
489
|
+
def email_field_tag(name, value = nil, options = {})
|
490
|
+
text_field_tag(name, value, options.stringify_keys.update("type" => "email"))
|
491
|
+
end
|
492
|
+
|
493
|
+
# Creates a number field.
|
494
|
+
#
|
495
|
+
# ==== Options
|
496
|
+
# * <tt>:min</tt> - The minimum acceptable value.
|
497
|
+
# * <tt>:max</tt> - The maximum acceptable value.
|
498
|
+
# * <tt>:in</tt> - A range specifying the <tt>:min</tt> and
|
499
|
+
# <tt>:max</tt> values.
|
500
|
+
# * <tt>:step</tt> - The acceptable value granularity.
|
501
|
+
# * Otherwise accepts the same options as text_field_tag.
|
502
|
+
#
|
503
|
+
# ==== Examples
|
504
|
+
# number_field_tag 'quantity', nil, :in => 1...10
|
505
|
+
# => <input id="quantity" name="quantity" min="1" max="9" />
|
506
|
+
def number_field_tag(name, value = nil, options = {})
|
507
|
+
options = options.stringify_keys
|
508
|
+
options["type"] ||= "number"
|
509
|
+
if range = options.delete("in") || options.delete("within")
|
510
|
+
options.update("min" => range.min, "max" => range.max)
|
511
|
+
end
|
512
|
+
text_field_tag(name, value, options)
|
513
|
+
end
|
514
|
+
|
515
|
+
# Creates a range form element.
|
516
|
+
#
|
517
|
+
# ==== Options
|
518
|
+
# * Accepts the same options as number_field_tag.
|
519
|
+
def range_field_tag(name, value = nil, options = {})
|
520
|
+
number_field_tag(name, value, options.stringify_keys.update("type" => "range"))
|
521
|
+
end
|
522
|
+
|
460
523
|
private
|
461
524
|
def html_options_for_form(url_for_options, options, *parameters_for_url)
|
462
525
|
returning options.stringify_keys do |html_options|
|
@@ -10,17 +10,24 @@ module ActionView
|
|
10
10
|
# This allows you to use the same format for links in views
|
11
11
|
# and controllers.
|
12
12
|
module UrlHelper
|
13
|
+
# This helper may be included in any class that includes the
|
14
|
+
# URL helpers of a router (router.url_helpers). Some methods
|
15
|
+
# provided here will only work in the context of a request
|
16
|
+
# (link_to_unless_current, for instance), which must be provided
|
17
|
+
# as a method called #request on the context.
|
18
|
+
|
13
19
|
extend ActiveSupport::Concern
|
14
20
|
|
15
21
|
include ActionDispatch::Routing::UrlFor
|
16
|
-
include
|
22
|
+
include TagHelper
|
17
23
|
|
18
24
|
# Need to map default url options to controller one.
|
19
|
-
def default_url_options(*args) #:nodoc:
|
20
|
-
|
21
|
-
end
|
22
|
-
|
25
|
+
# def default_url_options(*args) #:nodoc:
|
26
|
+
# controller.send(:default_url_options, *args)
|
27
|
+
# end
|
28
|
+
#
|
23
29
|
def url_options
|
30
|
+
return super unless controller.respond_to?(:url_options)
|
24
31
|
controller.url_options
|
25
32
|
end
|
26
33
|
|
@@ -97,7 +104,7 @@ module ActionView
|
|
97
104
|
when Hash
|
98
105
|
options = { :only_path => options[:host].nil? }.update(options.symbolize_keys)
|
99
106
|
escape = options.key?(:escape) ? options.delete(:escape) : false
|
100
|
-
|
107
|
+
super
|
101
108
|
when :back
|
102
109
|
escape = false
|
103
110
|
controller.request.env["HTTP_REFERER"] || 'javascript:history.back()'
|
@@ -119,13 +126,24 @@ module ActionView
|
|
119
126
|
#
|
120
127
|
# ==== Signatures
|
121
128
|
#
|
122
|
-
# link_to(
|
123
|
-
#
|
129
|
+
# link_to(body, url, html_options = {})
|
130
|
+
# # url is a String; you can use URL helpers like
|
131
|
+
# # posts_path
|
132
|
+
#
|
133
|
+
# link_to(body, url_options = {}, html_options = {})
|
134
|
+
# # url_options, except :confirm or :method,
|
135
|
+
# # is passed to url_for
|
136
|
+
#
|
137
|
+
# link_to(options = {}, html_options = {}) do
|
138
|
+
# # name
|
139
|
+
# end
|
140
|
+
#
|
141
|
+
# link_to(url, html_options = {}) do
|
124
142
|
# # name
|
125
143
|
# end
|
126
144
|
#
|
127
145
|
# ==== Options
|
128
|
-
# * <tt>:confirm => 'question?'</tt> - This will allow the unobtrusive JavaScript
|
146
|
+
# * <tt>:confirm => 'question?'</tt> - This will allow the unobtrusive JavaScript
|
129
147
|
# driver to prompt with the question specified. If the user accepts, the link is
|
130
148
|
# processed normally, otherwise no action is taken.
|
131
149
|
# * <tt>:method => symbol of HTTP verb</tt> - This modifier will dynamically
|
@@ -138,7 +156,11 @@ module ActionView
|
|
138
156
|
# disabled clicking the link will have no effect. If you are relying on the
|
139
157
|
# POST behavior, you should check for it in your controller's action by using
|
140
158
|
# the request object's methods for <tt>post?</tt>, <tt>delete?</tt> or <tt>put?</tt>.
|
141
|
-
# *
|
159
|
+
# * <tt>:remote => true</tt> - This will allow the unobtrusive JavaScript
|
160
|
+
# driver to make an Ajax request to the URL in question instead of following
|
161
|
+
# the link. The drivers each provide mechanisms for listening for the
|
162
|
+
# completion of the Ajax request and performing JavaScript operations once
|
163
|
+
# they're complete
|
142
164
|
#
|
143
165
|
# ==== Examples
|
144
166
|
# Because it relies on +url_for+, +link_to+ supports both older-style controller/action/id arguments
|
@@ -220,8 +242,8 @@ module ActionView
|
|
220
242
|
options = args[1] || {}
|
221
243
|
html_options = args[2]
|
222
244
|
|
223
|
-
url = url_for(options)
|
224
245
|
html_options = convert_options_to_data_attributes(options, html_options)
|
246
|
+
url = url_for(options)
|
225
247
|
|
226
248
|
if html_options
|
227
249
|
html_options = html_options.stringify_keys
|
@@ -243,7 +265,7 @@ module ActionView
|
|
243
265
|
# using the +link_to+ method with the <tt>:method</tt> modifier as described in
|
244
266
|
# the +link_to+ documentation.
|
245
267
|
#
|
246
|
-
# The generated form element has a class name of <tt>
|
268
|
+
# The generated form element has a class name of <tt>button_to</tt>
|
247
269
|
# to allow styling of the form itself and its children. You can control
|
248
270
|
# the form submission and input element behavior using +html_options+.
|
249
271
|
# This method accepts the <tt>:method</tt> and <tt>:confirm</tt> modifiers
|
@@ -259,22 +281,22 @@ module ActionView
|
|
259
281
|
# There are a few special +html_options+:
|
260
282
|
# * <tt>:method</tt> - Specifies the anchor name to be appended to the path.
|
261
283
|
# * <tt>:disabled</tt> - Specifies the anchor name to be appended to the path.
|
262
|
-
# * <tt>:confirm</tt> - This will use the unobtrusive JavaScript driver to
|
284
|
+
# * <tt>:confirm</tt> - This will use the unobtrusive JavaScript driver to
|
263
285
|
# prompt with the question specified. If the user accepts, the link is
|
264
286
|
# processed normally, otherwise no action is taken.
|
265
|
-
# * <tt>:remote</tt> - If set to true, will allow the Unobtrusive JavaScript drivers to control the
|
287
|
+
# * <tt>:remote</tt> - If set to true, will allow the Unobtrusive JavaScript drivers to control the
|
266
288
|
# submit behaviour. By default this behaviour is an ajax submit.
|
267
289
|
#
|
268
290
|
# ==== Examples
|
269
291
|
# <%= button_to "New", :action => "new" %>
|
270
|
-
# # => "<form method="post" action="/controller/new" class="
|
292
|
+
# # => "<form method="post" action="/controller/new" class="button_to">
|
271
293
|
# # <div><input value="New" type="submit" /></div>
|
272
294
|
# # </form>"
|
273
295
|
#
|
274
296
|
#
|
275
297
|
# <%= button_to "Delete Image", { :action => "delete", :id => @image.id },
|
276
298
|
# :confirm => "Are you sure?", :method => :delete %>
|
277
|
-
# # => "<form method="post" action="/images/delete/1" class="
|
299
|
+
# # => "<form method="post" action="/images/delete/1" class="button_to">
|
278
300
|
# # <div>
|
279
301
|
# # <input type="hidden" name="_method" value="delete" />
|
280
302
|
# # <input data-confirm='Are you sure?' value="Delete" type="submit" />
|
@@ -282,16 +304,15 @@ module ActionView
|
|
282
304
|
# # </form>"
|
283
305
|
#
|
284
306
|
#
|
285
|
-
# <%= button_to('Destroy', 'http://www.example.com', :confirm => 'Are you sure?',
|
307
|
+
# <%= button_to('Destroy', 'http://www.example.com', :confirm => 'Are you sure?',
|
286
308
|
# :method => "delete", :remote => true, :disable_with => 'loading...') %>
|
287
|
-
# # => "<form class='
|
309
|
+
# # => "<form class='button_to' method='post' action='http://www.example.com' data-remote='true'>
|
288
310
|
# # <div>
|
289
311
|
# # <input name='_method' value='delete' type='hidden' />
|
290
312
|
# # <input value='Destroy' type='submit' disable_with='loading...' data-confirm='Are you sure?' />
|
291
313
|
# # </div>
|
292
314
|
# # </form>"
|
293
315
|
# #
|
294
|
-
|
295
316
|
def button_to(name, options = {}, html_options = {})
|
296
317
|
html_options = html_options.stringify_keys
|
297
318
|
convert_boolean_attributes!(html_options, %w( disabled ))
|
@@ -317,7 +338,7 @@ module ActionView
|
|
317
338
|
|
318
339
|
html_options.merge!("type" => "submit", "value" => name)
|
319
340
|
|
320
|
-
("<form method=\"#{form_method}\" action=\"#{escape_once url}\" #{"data-remote=\"true\"" if remote} class=\"
|
341
|
+
("<form method=\"#{form_method}\" action=\"#{escape_once url}\" #{"data-remote=\"true\"" if remote} class=\"button_to\"><div>" +
|
321
342
|
method_tag + tag("input", html_options) + request_token_tag + "</div></form>").html_safe
|
322
343
|
end
|
323
344
|
|
@@ -546,8 +567,14 @@ module ActionView
|
|
546
567
|
# current_page?(:controller => 'library', :action => 'checkout')
|
547
568
|
# # => false
|
548
569
|
def current_page?(options)
|
570
|
+
unless request
|
571
|
+
raise "You cannot use helpers that need to determine the current " \
|
572
|
+
"page unless your view context provides a Request object " \
|
573
|
+
"in a #request method"
|
574
|
+
end
|
575
|
+
|
549
576
|
url_string = CGI.unescapeHTML(url_for(options))
|
550
|
-
|
577
|
+
|
551
578
|
# We ignore any extra parameters in the request_uri if the
|
552
579
|
# submitted url doesn't have any either. This lets the function
|
553
580
|
# work with things like ?order=asc
|
@@ -141,14 +141,6 @@
|
|
141
141
|
minute: "Minute"
|
142
142
|
second: "Seconds"
|
143
143
|
|
144
|
-
errors:
|
145
|
-
template:
|
146
|
-
header:
|
147
|
-
one: "1 error prohibited this {{model}} from being saved"
|
148
|
-
other: "{{count}} errors prohibited this {{model}} from being saved"
|
149
|
-
# The variable :count is also available
|
150
|
-
body: "There were problems with the following fields:"
|
151
|
-
|
152
144
|
helpers:
|
153
145
|
select:
|
154
146
|
# Default value for :prompt => true in FormOptionsHelper
|
@@ -38,7 +38,7 @@ module ActionView
|
|
38
38
|
end
|
39
39
|
|
40
40
|
register_detail(:formats) { Mime::SET.symbols }
|
41
|
-
register_detail(:locale) { [I18n.locale] }
|
41
|
+
register_detail(:locale) { [I18n.locale, I18n.default_locale] }
|
42
42
|
|
43
43
|
class DetailsKey #:nodoc:
|
44
44
|
alias :eql? :equal?
|
@@ -58,7 +58,7 @@ module ActionView
|
|
58
58
|
|
59
59
|
def initialize(view_paths, details = {})
|
60
60
|
@details, @details_key = { :handlers => default_handlers }, nil
|
61
|
-
@frozen_formats = false
|
61
|
+
@frozen_formats, @skip_default_locale = false, false
|
62
62
|
self.view_paths = view_paths
|
63
63
|
self.update_details(details, true)
|
64
64
|
end
|
@@ -147,7 +147,13 @@ module ActionView
|
|
147
147
|
super(value)
|
148
148
|
end
|
149
149
|
|
150
|
-
#
|
150
|
+
# Do not use the default locale on template lookup.
|
151
|
+
def skip_default_locale!
|
152
|
+
@skip_default_locale = true
|
153
|
+
self.locale = nil
|
154
|
+
end
|
155
|
+
|
156
|
+
# Overload locale to return a symbol instead of array.
|
151
157
|
def locale
|
152
158
|
@details[:locale].first
|
153
159
|
end
|
@@ -160,7 +166,8 @@ module ActionView
|
|
160
166
|
config = I18n.config.respond_to?(:i18n_config) ? I18n.config.i18n_config : I18n.config
|
161
167
|
config.locale = value
|
162
168
|
end
|
163
|
-
|
169
|
+
|
170
|
+
super(@skip_default_locale ? I18n.locale : _locale_defaults)
|
164
171
|
end
|
165
172
|
|
166
173
|
# Update the details keys by merging the given hash into the current
|
@@ -1,40 +1,54 @@
|
|
1
1
|
module ActionView
|
2
2
|
module Layouts
|
3
|
-
#
|
4
|
-
# returns the contents that are yielded to the layout. If the user calls yield
|
5
|
-
# :some_name, the block, by default, returns content_for(:some_name). If the user
|
6
|
-
# calls yield, the default block returns content_for(:layout).
|
3
|
+
# Returns the contents that are yielded to a layout, given a name or a block.
|
7
4
|
#
|
8
|
-
#
|
5
|
+
# You can think of a layout as a method that is called with a block. If the user calls
|
6
|
+
# <tt>yield :some_name</tt>, the block, by default, returns <tt>content_for(:some_name)</tt>.
|
7
|
+
# If the user calls simply +yield+, the default block returns <tt>content_for(:layout)</tt>.
|
9
8
|
#
|
10
|
-
#
|
9
|
+
# The user can override this default by passing a block to the layout:
|
11
10
|
#
|
12
11
|
# # The template
|
13
|
-
# <%= render :layout => "my_layout" do %>
|
12
|
+
# <%= render :layout => "my_layout" do %>
|
13
|
+
# Content
|
14
|
+
# <% end %>
|
14
15
|
#
|
15
16
|
# # The layout
|
16
|
-
# <html
|
17
|
+
# <html>
|
18
|
+
# <%= yield %>
|
19
|
+
# </html>
|
17
20
|
#
|
18
|
-
# In this case, instead of the default block, which would return content_for(:layout)
|
19
|
-
# this method returns the block that was passed in to render layout
|
20
|
-
# would be
|
21
|
+
# In this case, instead of the default block, which would return <tt>content_for(:layout)</tt>,
|
22
|
+
# this method returns the block that was passed in to <tt>render :layout</tt>, and the response
|
23
|
+
# would be
|
21
24
|
#
|
22
|
-
#
|
25
|
+
# <html>
|
26
|
+
# Content
|
27
|
+
# </html>
|
23
28
|
#
|
24
|
-
#
|
29
|
+
# Finally, the block can take block arguments, which can be passed in by +yield+:
|
25
30
|
#
|
26
31
|
# # The template
|
27
|
-
# <%= render :layout => "my_layout" do |customer| %>
|
32
|
+
# <%= render :layout => "my_layout" do |customer| %>
|
33
|
+
# Hello <%= customer.name %>
|
34
|
+
# <% end %>
|
28
35
|
#
|
29
36
|
# # The layout
|
30
|
-
# <html
|
37
|
+
# <html>
|
38
|
+
# <%= yield Struct.new(:name).new("David") %>
|
39
|
+
# </html>
|
31
40
|
#
|
32
41
|
# In this case, the layout would receive the block passed into <tt>render :layout</tt>,
|
33
|
-
# and the
|
34
|
-
# would be
|
42
|
+
# and the struct specified would be passed into the block as an argument. The result
|
43
|
+
# would be
|
44
|
+
#
|
45
|
+
# <html>
|
46
|
+
# Hello David
|
47
|
+
# </html>
|
48
|
+
#
|
35
49
|
def _layout_for(name = nil, &block) #:nodoc:
|
36
50
|
if !block || name
|
37
|
-
@_content_for[name || :layout]
|
51
|
+
@_content_for[name || :layout].html_safe
|
38
52
|
else
|
39
53
|
capture(&block)
|
40
54
|
end
|
@@ -179,7 +179,7 @@ module ActionView
|
|
179
179
|
|
180
180
|
def initialize(view_context, options, block)
|
181
181
|
@view = view_context
|
182
|
-
@partial_names = PARTIAL_NAMES[@view.controller.class]
|
182
|
+
@partial_names = PARTIAL_NAMES[@view.controller.class.name]
|
183
183
|
|
184
184
|
setup(options, block)
|
185
185
|
end
|
@@ -300,7 +300,7 @@ module ActionView
|
|
300
300
|
end
|
301
301
|
|
302
302
|
def partial_path(object = @object)
|
303
|
-
@partial_names[object.class] ||= begin
|
303
|
+
@partial_names[object.class.name] ||= begin
|
304
304
|
object = object.to_model if object.respond_to?(:to_model)
|
305
305
|
|
306
306
|
object.class.model_name.partial_path.dup.tap do |partial|
|