mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Added current_page?(options) method to check if the url_for options passed corresponds to the current page
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@645 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
3e4064e9f2
commit
761b18a564
1 changed files with 6 additions and 1 deletions
|
@ -78,7 +78,7 @@ module ActionView
|
||||||
# given block is yielded, if one exists). This is useful for creating link bars where you don't want to link
|
# given block is yielded, if one exists). This is useful for creating link bars where you don't want to link
|
||||||
# to the page currently being viewed.
|
# to the page currently being viewed.
|
||||||
def link_to_unless_current(name, options = {}, html_options = {}, *parameters_for_method_reference)
|
def link_to_unless_current(name, options = {}, html_options = {}, *parameters_for_method_reference)
|
||||||
if url_for(options) == @request.request_uri
|
if current_page?(options)
|
||||||
block_given? ?
|
block_given? ?
|
||||||
yield(name, options, html_options, *parameters_for_method_reference) :
|
yield(name, options, html_options, *parameters_for_method_reference) :
|
||||||
html_escape(name)
|
html_escape(name)
|
||||||
|
@ -120,6 +120,11 @@ module ActionView
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns true if the current page uri is generated by the options passed (in url_for format).
|
||||||
|
def current_page?(options)
|
||||||
|
url_for(options) == @request.request_uri
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def convert_confirm_option_to_javascript!(html_options)
|
def convert_confirm_option_to_javascript!(html_options)
|
||||||
if html_options.include?(:confirm)
|
if html_options.include?(:confirm)
|
||||||
|
|
Loading…
Reference in a new issue