diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-06-06 04:13:09 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-06-06 04:13:09 -0700 |
commit | e2c49e6a59f1b969a526586a3dd4dfd9c6f12b10 (patch) | |
tree | 9354aa962ad01710c87891ef8bb7d2dd7ca45526 | |
parent | fd40fbc1983a96587cc25729985191573a03e04c (diff) | |
download | rails-e2c49e6a59f1b969a526586a3dd4dfd9c6f12b10.tar.gz rails-e2c49e6a59f1b969a526586a3dd4dfd9c6f12b10.tar.bz2 rails-e2c49e6a59f1b969a526586a3dd4dfd9c6f12b10.zip |
Drop a string conversion from the often-called tag_options helper
-rw-r--r-- | actionpack/lib/action_view/helpers/tag_helper.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb index 999cbfb52a..ba43b5e8ef 100644 --- a/actionpack/lib/action_view/helpers/tag_helper.rb +++ b/actionpack/lib/action_view/helpers/tag_helper.rb @@ -1,5 +1,6 @@ require 'cgi' require 'erb' +require 'set' module ActionView module Helpers #:nodoc: @@ -8,7 +9,8 @@ module ActionView module TagHelper include ERB::Util - BOOLEAN_ATTRIBUTES = Set.new(%w(disabled readonly multiple)) + BOOLEAN_ATTRIBUTES = %w(disabled readonly multiple).to_set + BOOLEAN_ATTRIBUTES.merge(BOOLEAN_ATTRIBUTES.map(&:to_sym)) # Returns an empty HTML tag of type +name+ which by default is XHTML # compliant. Set +open+ to true to create an open tag compatible @@ -37,7 +39,7 @@ module ActionView # tag("img", { :src => "open & shut.png" }, false, false) # # => <img src="open & shut.png" /> def tag(name, options = nil, open = false, escape = true) - "<#{name}#{tag_options(options, escape) if options}" + (open ? ">" : " />") + "<#{name}#{tag_options(options, escape) if options}#{open ? ">" : " />"}" end # Returns an HTML block tag of type +name+ surrounding the +content+. Add @@ -114,7 +116,6 @@ module ActionView if escape options.each do |key, value| next unless value - key = key.to_s value = BOOLEAN_ATTRIBUTES.include?(key) ? key : escape_once(value) attrs << %(#{key}="#{value}") end |