From d611036c7709d7c30cbab3110e20e248283af364 Mon Sep 17 00:00:00 2001 From: Frank Groeneveld Date: Fri, 17 Oct 2014 08:21:56 +0200 Subject: Use include_blank value as option label Update select_tag to reflect documentation and behave the same as form builder select. If the value of include_blank is not boolean true, use that value as the option label. --- actionview/lib/action_view/helpers/form_tag_helper.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/helpers/form_tag_helper.rb b/actionview/lib/action_view/helpers/form_tag_helper.rb index 7d1cdc5a68..cf1e20cf55 100644 --- a/actionview/lib/action_view/helpers/form_tag_helper.rb +++ b/actionview/lib/action_view/helpers/form_tag_helper.rb @@ -133,8 +133,14 @@ module ActionView option_tags ||= "" html_name = (options[:multiple] == true && !name.to_s.ends_with?("[]")) ? "#{name}[]" : name - if options.delete(:include_blank) - option_tags = content_tag(:option, '', :value => '').safe_concat(option_tags) + + if options.include?(:include_blank) + include_blank = options.delete(:include_blank) + if include_blank == true + include_blank = '' + end + + option_tags = content_tag(:option, include_blank, :value => '').safe_concat(option_tags) end if prompt = options.delete(:prompt) -- cgit v1.2.3 From 95acea5498f1e9ac43cf87b55578e0a8d576680b Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Sat, 25 Oct 2014 23:19:27 +0530 Subject: Clarify comments about sanitized_allowed_tags - Clarify that arguments are expected in array format. - Extension of https://github.com/rails/rails/pull/17390. - https://github.com/rails/rails/pull/17390 was targeted against 4-1-stable branch. This commit updates master. - [ci skip] --- actionview/lib/action_view/helpers/sanitize_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/helpers/sanitize_helper.rb b/actionview/lib/action_view/helpers/sanitize_helper.rb index 4f2db0a0c4..7cb55cc214 100644 --- a/actionview/lib/action_view/helpers/sanitize_helper.rb +++ b/actionview/lib/action_view/helpers/sanitize_helper.rb @@ -57,7 +57,7 @@ module ActionView # Add table tags to the default allowed tags # # class Application < Rails::Application - # config.action_view.sanitized_allowed_tags = 'table', 'tr', 'td' + # config.action_view.sanitized_allowed_tags = ['table', 'tr', 'td'] # end # # Remove tags to the default allowed tags @@ -176,7 +176,7 @@ module ActionView # Replaces the allowed tags for the +sanitize+ helper. # # class Application < Rails::Application - # config.action_view.sanitized_allowed_tags = 'table', 'tr', 'td' + # config.action_view.sanitized_allowed_tags = ['table', 'tr', 'td'] # end # -- cgit v1.2.3 From f28340a5ef3dafd3f96e7032b6b21352ebd11f57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sat, 25 Oct 2014 16:13:58 -0700 Subject: :scissors: --- actionview/lib/action_view/helpers/form_tag_helper.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/helpers/form_tag_helper.rb b/actionview/lib/action_view/helpers/form_tag_helper.rb index 74cfec962e..5aeb138f7a 100644 --- a/actionview/lib/action_view/helpers/form_tag_helper.rb +++ b/actionview/lib/action_view/helpers/form_tag_helper.rb @@ -133,13 +133,12 @@ module ActionView option_tags ||= "" html_name = (options[:multiple] == true && !name.to_s.ends_with?("[]")) ? "#{name}[]" : name - if options.include?(:include_blank) include_blank = options.delete(:include_blank) if include_blank == true include_blank = '' end - + option_tags = content_tag(:option, include_blank, :value => '').safe_concat(option_tags) end -- cgit v1.2.3 From b2278aa1a0c02f8793587f625900504b447b4517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sat, 25 Oct 2014 16:14:28 -0700 Subject: Use new hash syntax --- actionview/lib/action_view/helpers/form_tag_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/helpers/form_tag_helper.rb b/actionview/lib/action_view/helpers/form_tag_helper.rb index 5aeb138f7a..c0218fd55d 100644 --- a/actionview/lib/action_view/helpers/form_tag_helper.rb +++ b/actionview/lib/action_view/helpers/form_tag_helper.rb @@ -135,15 +135,16 @@ module ActionView if options.include?(:include_blank) include_blank = options.delete(:include_blank) + if include_blank == true include_blank = '' end - option_tags = content_tag(:option, include_blank, :value => '').safe_concat(option_tags) + option_tags = content_tag(:option, include_blank, value: '').safe_concat(option_tags) end if prompt = options.delete(:prompt) - option_tags = content_tag(:option, prompt, :value => '').safe_concat(option_tags) + option_tags = content_tag(:option, prompt, value: '').safe_concat(option_tags) end content_tag :select, option_tags, { "name" => html_name, "id" => sanitize_to_id(name) }.update(options.stringify_keys) -- cgit v1.2.3 From 44260581bec06e4ce05f3dd838c8b4736fc7eb1d Mon Sep 17 00:00:00 2001 From: Ryunosuke SATO Date: Wed, 29 Oct 2014 00:32:43 +0900 Subject: Fix doc markup for `NumberHelper` [ci skip] The character "*" is unnecessary in option candidates. This incorrect markup was injected in e8c9aeca . --- actionview/lib/action_view/helpers/number_helper.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/helpers/number_helper.rb b/actionview/lib/action_view/helpers/number_helper.rb index 7220bded3c..f66dbfe7d3 100644 --- a/actionview/lib/action_view/helpers/number_helper.rb +++ b/actionview/lib/action_view/helpers/number_helper.rb @@ -306,12 +306,12 @@ module ActionView # string containing an i18n scope where to find this hash. It # might have the following keys: # * *integers*: :unit, :ten, - # *:hundred, :thousand, :million, - # *:billion, :trillion, - # *:quadrillion + # :hundred, :thousand, :million, + # :billion, :trillion, + # :quadrillion # * *fractionals*: :deci, :centi, - # *:mili, :micro, :nano, - # *:pico, :femto + # :mili, :micro, :nano, + # :pico, :femto # * :format - Sets the format of the output string # (defaults to "%n %u"). The field types are: # * %u - The quantifier (ex.: 'thousand') -- cgit v1.2.3 From b3bfa361c503e107aff4dee5edf79bd7fd3d3725 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 28 Oct 2014 16:17:33 -0700 Subject: let's warn with heredocs The current style for warning messages without newlines uses concatenation of string literals with manual trailing spaces where needed. Heredocs have better readability, and with `squish` we can still produce a single line. This is a similar use case to the one that motivated defining `strip_heredoc`, heredocs are super clean. --- actionview/lib/action_view/template/resolver.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb index d77421d5f5..b65507f4a2 100644 --- a/actionview/lib/action_view/template/resolver.rb +++ b/actionview/lib/action_view/template/resolver.rb @@ -1,6 +1,7 @@ require "pathname" require "active_support/core_ext/class" require "active_support/core_ext/module/attribute_accessors" +require 'active_support/core_ext/string/filters' require "action_view/template" require "thread" require "thread_safe" @@ -251,9 +252,10 @@ module ActionView extension = pieces.pop unless extension - message = "The file #{path} did not specify a template handler. The default is currently ERB, " \ - "but will change to RAW in the future." - ActiveSupport::Deprecation.warn message + ActiveSupport::Deprecation.warn(<<-MSG.squish) + The file #{path} did not specify a template handler. The default is + currently ERB, but will change to RAW in the future. + MSG end handler = Template.handler_for_extension(extension) -- cgit v1.2.3 From e595d91ac2c07371b441f8b04781e7c03ac44135 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 28 Oct 2014 17:33:36 -0700 Subject: edit pass over all warnings This patch uniformizes warning messages. I used the most common style already present in the code base: * Capitalize the first word. * End the message with a full stop. * "Rails 5" instead of "Rails 5.0". * Backticks for method names and inline code. Also, converted a few long strings into the new heredoc convention. --- actionview/lib/action_view/view_paths.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/view_paths.rb b/actionview/lib/action_view/view_paths.rb index 80a41f2418..2e203a7590 100644 --- a/actionview/lib/action_view/view_paths.rb +++ b/actionview/lib/action_view/view_paths.rb @@ -38,7 +38,11 @@ module ActionView def handle_deprecated_parent_prefixes # TODO: remove in 4.3/5.0. return unless respond_to?(:parent_prefixes) - ActiveSupport::Deprecation.warn "Overriding ActionController::Base::parent_prefixes is deprecated, override .local_prefixes instead." + ActiveSupport::Deprecation.warn(<<-MSG.squish) + Overriding `ActionController::Base::parent_prefixes` is deprecated, + override `.local_prefixes` instead. + MSG + local_prefixes + parent_prefixes end end -- cgit v1.2.3 From 724db9eb6236eb21051d85438b62e452765ee291 Mon Sep 17 00:00:00 2001 From: Pablo Herrero Date: Wed, 29 Oct 2014 20:51:32 -0300 Subject: Fix typo at form_helper docs [ci skip] --- actionview/lib/action_view/helpers/form_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/helpers/form_helper.rb b/actionview/lib/action_view/helpers/form_helper.rb index 038f9e384b..03f80ff360 100644 --- a/actionview/lib/action_view/helpers/form_helper.rb +++ b/actionview/lib/action_view/helpers/form_helper.rb @@ -1231,8 +1231,8 @@ module ActionView # end # # The above code creates a new method +div_radio_button+ which wraps a div - # around the a new radio button. Note that when options are passed in, you - # must called +objectify_options+ in order for the model object to get + # around the new radio button. Note that when options are passed in, you + # must call +objectify_options+ in order for the model object to get # correctly passed to the method. If +objectify_options+ is not called, # then the newly created helper will not be linked back to the model. # -- cgit v1.2.3 From 4daebedcc41e35079c47d5f130f5c7ad12db8bbb Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Thu, 30 Oct 2014 14:09:21 -0700 Subject: Prepare for 4.2.0.beta4 release --- actionview/lib/action_view/gem_version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/gem_version.rb b/actionview/lib/action_view/gem_version.rb index 076b8ec30b..752eafee3c 100644 --- a/actionview/lib/action_view/gem_version.rb +++ b/actionview/lib/action_view/gem_version.rb @@ -8,7 +8,7 @@ module ActionView MAJOR = 4 MINOR = 2 TINY = 0 - PRE = "beta2" + PRE = "beta4" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end -- cgit v1.2.3 From f0570a3d3fa85ba0153d61c90bad6db648144256 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Mon, 24 Feb 2014 17:05:42 +0100 Subject: Honor public/private in ActionView::Helpers::Tags::Base#value * use public_send instead of send to avoid calling private methods in form helpers --- actionview/lib/action_view/helpers/tags/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/helpers/tags/base.rb b/actionview/lib/action_view/helpers/tags/base.rb index 8607da301c..f8abb19698 100644 --- a/actionview/lib/action_view/helpers/tags/base.rb +++ b/actionview/lib/action_view/helpers/tags/base.rb @@ -25,7 +25,7 @@ module ActionView private def value(object) - object.send @method_name if object + object.public_send @method_name if object end def value_before_type_cast(object) -- cgit v1.2.3 From 861b70e92f4a1fc0e465ffcf2ee62680519c8f6f Mon Sep 17 00:00:00 2001 From: Pablo Herrero Date: Sat, 1 Nov 2014 20:16:03 -0300 Subject: Call gsub with a Regexp instead of a String for better performance --- actionview/lib/action_view/helpers/tag_helper.rb | 2 +- actionview/lib/action_view/template/handlers/raw.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/helpers/tag_helper.rb b/actionview/lib/action_view/helpers/tag_helper.rb index 385d57a7a5..b2038576a2 100644 --- a/actionview/lib/action_view/helpers/tag_helper.rb +++ b/actionview/lib/action_view/helpers/tag_helper.rb @@ -123,7 +123,7 @@ module ActionView # cdata_section("hello]]>world") # # => world]]> def cdata_section(content) - splitted = content.to_s.gsub(']]>', ']]]]>') + splitted = content.to_s.gsub(/\]\]\>/, ']]]]>') "".html_safe end diff --git a/actionview/lib/action_view/template/handlers/raw.rb b/actionview/lib/action_view/template/handlers/raw.rb index 0c0d1fffcb..397c86014a 100644 --- a/actionview/lib/action_view/template/handlers/raw.rb +++ b/actionview/lib/action_view/template/handlers/raw.rb @@ -2,7 +2,7 @@ module ActionView module Template::Handlers class Raw def call(template) - escaped = template.source.gsub(':', '\:') + escaped = template.source.gsub(/:/, '\:') '%q:' + escaped + ':;' end -- cgit v1.2.3