mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #5174 from nashby/safe-concat
use content_tag instead of strings
This commit is contained in:
commit
cbe74cf024
1 changed files with 4 additions and 3 deletions
|
@ -133,13 +133,14 @@ module ActionView
|
||||||
|
|
||||||
def add_options(option_tags, options, value = nil)
|
def add_options(option_tags, options, value = nil)
|
||||||
if options[:include_blank]
|
if options[:include_blank]
|
||||||
option_tags = "<option value=\"\">#{ERB::Util.html_escape(options[:include_blank]) if options[:include_blank].kind_of?(String)}</option>\n" + option_tags
|
include_blank = options[:include_blank] if options[:include_blank].kind_of?(String)
|
||||||
|
option_tags = content_tag(:option, include_blank, :value => '').safe_concat("\n").safe_concat(option_tags)
|
||||||
end
|
end
|
||||||
if value.blank? && options[:prompt]
|
if value.blank? && options[:prompt]
|
||||||
prompt = options[:prompt].kind_of?(String) ? options[:prompt] : I18n.translate('helpers.select.prompt', :default => 'Please select')
|
prompt = options[:prompt].kind_of?(String) ? options[:prompt] : I18n.translate('helpers.select.prompt', :default => 'Please select')
|
||||||
option_tags = "<option value=\"\">#{ERB::Util.html_escape(prompt)}</option>\n" + option_tags
|
option_tags = content_tag(:option, prompt, :value => '').safe_concat("\n").safe_concat(option_tags)
|
||||||
end
|
end
|
||||||
option_tags.html_safe
|
option_tags
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue