aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/tag_helper.rb19
-rw-r--r--actionpack/lib/action_view/helpers/url_helper.rb17
3 files changed, 18 insertions, 20 deletions
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index fea7abe3f9..efde8fa51b 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -121,7 +121,7 @@ module ActionView
def compute_public_path(source, dir, ext)
source = "/#{dir}/#{source}" unless source.first == "/" || source.include?(":")
source = "#{source}.#{ext}" unless source.include?(".")
- source = "#{@request.relative_url_root}#{source}" unless %r{^[-a-z]+://} =~ source
+ source = "#{@controller.request.relative_url_root}#{source}" unless %r{^[-a-z]+://} =~ source
ActionController::Base.asset_host + source
end
end
diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb
index 40fd72d23f..8b2d2c3a5a 100644
--- a/actionpack/lib/action_view/helpers/tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/tag_helper.rb
@@ -10,27 +10,26 @@ module ActionView
# Examples:
# * <tt>tag("br") => <br /></tt>
# * <tt>tag("input", { "type" => "text"}) => <input type="text" /></tt>
- def tag(name, options = {}, open = false)
- "<#{name}#{tag_options(options)}" + (open ? ">" : " />")
+ def tag(name, options = nil, open = false)
+ "<#{name}#{tag_options(options.stringify_keys) if options}" + (open ? ">" : " />")
end
# Examples:
# * <tt>content_tag("p", "Hello world!") => <p>Hello world!</p></tt>
# * <tt>content_tag("div", content_tag("p", "Hello world!"), "class" => "strong") => </tt>
# <tt><div class="strong"><p>Hello world!</p></div></tt>
- def content_tag(name, content, options = {})
- "<#{name}#{tag_options(options)}>#{content}</#{name}>"
+ def content_tag(name, content, options = nil)
+ "<#{name}#{tag_options(options.stringify_keys) if options}>#{content}</#{name}>"
end
private
def tag_options(options)
- cleaned_options = options.reject { |key, value| value.nil? }
- unless cleaned_options.empty?
- " " + cleaned_options.symbolize_keys.map { |key, value|
- %(#{key}="#{html_escape(value.to_s)}")
- }.sort.join(" ")
+ if options
+ options.inject("") do |html_str, (key, value)|
+ value.nil? ? html_str : html_str << %( #{key}="#{html_escape(value)}")
+ end
end
end
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb
index d154f7c00c..4b7a2270dc 100644
--- a/actionpack/lib/action_view/helpers/url_helper.rb
+++ b/actionpack/lib/action_view/helpers/url_helper.rb
@@ -39,16 +39,15 @@ module ActionView
# link_to "Busy loop", { :action => "busy" }, :popup => ['new_window', 'height=300,width=600']
# link_to "Destroy account", { :action => "destroy" }, :confirm => "Are you sure?", :post => true
def link_to(name, options = {}, html_options = nil, *parameters_for_method_reference)
- html_options = (html_options || {}).stringify_keys
- convert_options_to_javascript!(html_options)
- if options.is_a?(String)
- content_tag "a", name || options, (html_options || {}).merge("href" => options)
+ if html_options
+ html_options = html_options.stringify_keys
+ convert_options_to_javascript!(html_options)
+ tag_options = tag_options(html_options)
else
- content_tag(
- "a", name || url_for(options, *parameters_for_method_reference),
- (html_options || {}).merge("href" => url_for(options, *parameters_for_method_reference))
- )
+ tag_options = nil
end
+ url = options.is_a?(String) ? options : url_for(options, *parameters_for_method_reference)
+ "<a href=\"#{url}\"#{tag_options}>#{name||url}</a>"
end
# Generates a form containing a sole button that submits to the
@@ -236,7 +235,7 @@ module ActionView
# 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
+ url_for(options) == @controller.request.request_uri
end
private