mirror of
https://github.com/github/rails.git
synced 2026-01-25 14:28:28 -05:00
Added option to pass in parameters to CaptureHelper#capture, so you can create more advanced view helper methods #1466 [duane.johnson@gmail.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1459 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
*SVN*
|
||||
|
||||
* Added option to pass in parameters to CaptureHelper#capture, so you can create more advanced view helper methods #1466 [duane.johnson@gmail.com]. Example:
|
||||
|
||||
<% show_calendar(:year => 2005, :month => 6) do |day, options| %>
|
||||
<% options[:bgcolor] = '#dfd' if 10..15.include? day %>
|
||||
[<%= day %>]
|
||||
<% end %>
|
||||
|
||||
* Changed the default name of the input tag generated by FormTagHelper#submit_tag from "submit" to "commit" so it doesn't clash with form.submit() calls in Javascript #1271
|
||||
|
||||
* Fixed relative urls support for lighttpd #1048 [Nicholas Seckar/maznawak@nerim.net]
|
||||
|
||||
@@ -48,11 +48,11 @@ module ActionView
|
||||
# <% @greeting = capture do %>
|
||||
# Welcome To my shiny new web page!
|
||||
# <% end %>
|
||||
def capture(&block)
|
||||
def capture(*args, &block)
|
||||
# execute the block
|
||||
buffer = eval("_erbout", block.binding)
|
||||
pos = buffer.length
|
||||
block.call
|
||||
block.call(*args)
|
||||
|
||||
# extract the block
|
||||
data = buffer[pos..-1]
|
||||
@@ -77,7 +77,10 @@ module ActionView
|
||||
# alert('hello world')
|
||||
# <% end %>
|
||||
#
|
||||
# You can use @content_for_header anywhere in your templates
|
||||
# You can use @content_for_header anywhere in your templates.
|
||||
#
|
||||
# NOTE: Beware that content_for is ignored in caches. So you shouldn't use it
|
||||
# for elements that are going to be fragment cached.
|
||||
def content_for(name, &block)
|
||||
base = controller.instance_variable_get(instance_var_name(name)) || ""
|
||||
data = capture(&block)
|
||||
@@ -85,8 +88,7 @@ module ActionView
|
||||
data
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
private
|
||||
def instance_var_name(name) #:nodoc#
|
||||
"@content_for_#{name}"
|
||||
end
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user