aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view
diff options
context:
space:
mode:
Diffstat (limited to 'actionview/lib/action_view')
-rw-r--r--actionview/lib/action_view/base.rb22
-rw-r--r--actionview/lib/action_view/buffers.rb2
-rw-r--r--actionview/lib/action_view/dependency_tracker.rb8
-rw-r--r--actionview/lib/action_view/digestor.rb10
-rw-r--r--actionview/lib/action_view/flows.rb9
-rw-r--r--actionview/lib/action_view/helpers.rb2
-rw-r--r--actionview/lib/action_view/helpers/active_model_helper.rb16
-rw-r--r--actionview/lib/action_view/helpers/asset_tag_helper.rb38
-rw-r--r--actionview/lib/action_view/helpers/asset_url_helper.rb28
-rw-r--r--actionview/lib/action_view/helpers/atom_feed_helper.rb17
-rw-r--r--actionview/lib/action_view/helpers/capture_helper.rb2
-rw-r--r--actionview/lib/action_view/helpers/controller_helper.rb4
-rw-r--r--actionview/lib/action_view/helpers/csrf_helper.rb6
-rw-r--r--actionview/lib/action_view/helpers/date_helper.rb190
-rw-r--r--actionview/lib/action_view/helpers/debug_helper.rb5
-rw-r--r--actionview/lib/action_view/helpers/form_helper.rb30
-rw-r--r--actionview/lib/action_view/helpers/form_options_helper.rb16
-rw-r--r--actionview/lib/action_view/helpers/form_tag_helper.rb52
-rw-r--r--actionview/lib/action_view/helpers/javascript_helper.rb10
-rw-r--r--actionview/lib/action_view/helpers/number_helper.rb84
-rw-r--r--actionview/lib/action_view/helpers/output_safety_helper.rb10
-rw-r--r--actionview/lib/action_view/helpers/rendering_helper.rb4
-rw-r--r--actionview/lib/action_view/helpers/sanitize_helper.rb4
-rw-r--r--actionview/lib/action_view/helpers/tag_helper.rb11
-rw-r--r--actionview/lib/action_view/helpers/tags/base.rb198
-rw-r--r--actionview/lib/action_view/helpers/tags/check_box.rb34
-rw-r--r--actionview/lib/action_view/helpers/tags/collection_check_boxes.rb14
-rw-r--r--actionview/lib/action_view/helpers/tags/collection_helpers.rb114
-rw-r--r--actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb2
-rw-r--r--actionview/lib/action_view/helpers/tags/collection_select.rb4
-rw-r--r--actionview/lib/action_view/helpers/tags/date_select.rb70
-rw-r--r--actionview/lib/action_view/helpers/tags/grouped_collection_select.rb4
-rw-r--r--actionview/lib/action_view/helpers/tags/password_field.rb2
-rw-r--r--actionview/lib/action_view/helpers/tags/radio_button.rb8
-rw-r--r--actionview/lib/action_view/helpers/tags/select.rb10
-rw-r--r--actionview/lib/action_view/helpers/tags/text_area.rb2
-rw-r--r--actionview/lib/action_view/helpers/tags/text_field.rb8
-rw-r--r--actionview/lib/action_view/helpers/tags/translator.rb24
-rw-r--r--actionview/lib/action_view/helpers/text_helper.rb26
-rw-r--r--actionview/lib/action_view/helpers/translation_helper.rb12
-rw-r--r--actionview/lib/action_view/helpers/url_helper.rb58
-rw-r--r--actionview/lib/action_view/layouts.rb62
-rw-r--r--actionview/lib/action_view/log_subscriber.rb6
-rw-r--r--actionview/lib/action_view/lookup_context.rb12
-rw-r--r--actionview/lib/action_view/path_set.rb38
-rw-r--r--actionview/lib/action_view/record_identifier.rb8
-rw-r--r--actionview/lib/action_view/renderer/abstract_renderer.rb32
-rw-r--r--actionview/lib/action_view/renderer/partial_renderer.rb330
-rw-r--r--actionview/lib/action_view/renderer/streaming_template_renderer.rb90
-rw-r--r--actionview/lib/action_view/renderer/template_renderer.rb120
-rw-r--r--actionview/lib/action_view/routing_url_for.rb3
-rw-r--r--actionview/lib/action_view/tasks/cache_digests.rake14
-rw-r--r--actionview/lib/action_view/template.rb18
-rw-r--r--actionview/lib/action_view/template/error.rb8
-rw-r--r--actionview/lib/action_view/template/handlers.rb8
-rw-r--r--actionview/lib/action_view/template/handlers/builder.rb10
-rw-r--r--actionview/lib/action_view/template/handlers/erb.rb20
-rw-r--r--actionview/lib/action_view/template/html.rb4
-rw-r--r--actionview/lib/action_view/template/resolver.rb152
-rw-r--r--actionview/lib/action_view/template/text.rb4
-rw-r--r--actionview/lib/action_view/template/types.rb2
-rw-r--r--actionview/lib/action_view/test_case.rb19
-rw-r--r--actionview/lib/action_view/testing/resolvers.rb18
-rw-r--r--actionview/lib/action_view/version.rb2
-rw-r--r--actionview/lib/action_view/view_paths.rb8
65 files changed, 1075 insertions, 1083 deletions
diff --git a/actionview/lib/action_view/base.rb b/actionview/lib/action_view/base.rb
index 0ede884c94..d9a9d3d8ce 100644
--- a/actionview/lib/action_view/base.rb
+++ b/actionview/lib/action_view/base.rb
@@ -1,11 +1,11 @@
-require 'active_support/core_ext/module/attr_internal'
-require 'active_support/core_ext/module/attribute_accessors'
-require 'active_support/ordered_options'
-require 'action_view/log_subscriber'
-require 'action_view/helpers'
-require 'action_view/context'
-require 'action_view/template'
-require 'action_view/lookup_context'
+require "active_support/core_ext/module/attr_internal"
+require "active_support/core_ext/module/attribute_accessors"
+require "active_support/ordered_options"
+require "action_view/log_subscriber"
+require "action_view/helpers"
+require "action_view/context"
+require "action_view/template"
+require "action_view/lookup_context"
module ActionView #:nodoc:
# = Action View Base
@@ -169,7 +169,7 @@ module ActionView #:nodoc:
class_attribute :logger
class << self
- delegate :erb_trim_mode=, :to => 'ActionView::Template::Handlers::ERB'
+ delegate :erb_trim_mode=, to: "ActionView::Template::Handlers::ERB"
def cache_template_loading
ActionView::Resolver.caching?
@@ -187,8 +187,8 @@ module ActionView #:nodoc:
attr_accessor :view_renderer
attr_internal :config, :assigns
- delegate :lookup_context, :to => :view_renderer
- delegate :formats, :formats=, :locale, :locale=, :view_paths, :view_paths=, :to => :lookup_context
+ delegate :lookup_context, to: :view_renderer
+ delegate :formats, :formats=, :locale, :locale=, :view_paths, :view_paths=, to: :lookup_context
def assign(new_assigns) # :nodoc:
@_assigns = new_assigns.each { |key, value| instance_variable_set("@#{key}", value) }
diff --git a/actionview/lib/action_view/buffers.rb b/actionview/lib/action_view/buffers.rb
index be5d86b1dc..089daa6d60 100644
--- a/actionview/lib/action_view/buffers.rb
+++ b/actionview/lib/action_view/buffers.rb
@@ -1,4 +1,4 @@
-require 'active_support/core_ext/string/output_safety'
+require "active_support/core_ext/string/output_safety"
module ActionView
class OutputBuffer < ActiveSupport::SafeBuffer #:nodoc:
diff --git a/actionview/lib/action_view/dependency_tracker.rb b/actionview/lib/action_view/dependency_tracker.rb
index 7731773040..67d98e9721 100644
--- a/actionview/lib/action_view/dependency_tracker.rb
+++ b/actionview/lib/action_view/dependency_tracker.rb
@@ -1,5 +1,5 @@
-require 'concurrent/map'
-require 'action_view/path_set'
+require "concurrent/map"
+require "action_view/path_set"
module ActionView
class DependencyTracker # :nodoc:
@@ -142,7 +142,7 @@ module ActionView
def add_static_dependency(dependencies, dependency)
if dependency
- if dependency.include?('/')
+ if dependency.include?("/")
dependencies << dependency
else
dependencies << "#{directory}/#{dependency}"
@@ -163,7 +163,7 @@ module ActionView
def explicit_dependencies
dependencies = source.scan(EXPLICIT_DEPENDENCY).flatten.uniq
- wildcards, explicits = dependencies.partition { |dependency| dependency[-1] == '*' }
+ wildcards, explicits = dependencies.partition { |dependency| dependency[-1] == "*" }
(explicits + resolve_directories(wildcards)).uniq
end
diff --git a/actionview/lib/action_view/digestor.rb b/actionview/lib/action_view/digestor.rb
index cadef22022..2d6ad8f6d9 100644
--- a/actionview/lib/action_view/digestor.rb
+++ b/actionview/lib/action_view/digestor.rb
@@ -1,6 +1,6 @@
-require 'concurrent/map'
-require 'action_view/dependency_tracker'
-require 'monitor'
+require "concurrent/map"
+require "action_view/dependency_tracker"
+require "monitor"
module ActionView
class Digestor
@@ -14,7 +14,7 @@ module ActionView
# * <tt>dependencies</tt> - An array of dependent views
def digest(name:, finder:, dependencies: [])
dependencies ||= []
- cache_key = [ name, finder.rendered_format, dependencies ].flatten.compact.join('.')
+ cache_key = [ name, finder.rendered_format, dependencies ].flatten.compact.join(".")
# this is a correctly done double-checked locking idiom
# (Concurrent::Map's lookups have volatile semantics)
@@ -103,7 +103,7 @@ module ActionView
class Partial < Node; end
class Missing < Node
- def digest(finder, _ = []) '' end
+ def digest(finder, _ = []) "" end
end
class Injected < Node
diff --git a/actionview/lib/action_view/flows.rb b/actionview/lib/action_view/flows.rb
index 4b912f0b2b..16874c1194 100644
--- a/actionview/lib/action_view/flows.rb
+++ b/actionview/lib/action_view/flows.rb
@@ -1,4 +1,4 @@
-require 'active_support/core_ext/string/output_safety'
+require "active_support/core_ext/string/output_safety"
module ActionView
class OutputFlow #:nodoc:
@@ -23,7 +23,6 @@ module ActionView
@content[key] << value
end
alias_method :append!, :append
-
end
class StreamingFlow < OutputFlow #:nodoc:
@@ -68,8 +67,8 @@ module ActionView
private
- def inside_fiber?
- Fiber.current.object_id != @root
- end
+ def inside_fiber?
+ Fiber.current.object_id != @root
+ end
end
end
diff --git a/actionview/lib/action_view/helpers.rb b/actionview/lib/action_view/helpers.rb
index 787e9d67b2..c1b4b4f84b 100644
--- a/actionview/lib/action_view/helpers.rb
+++ b/actionview/lib/action_view/helpers.rb
@@ -1,4 +1,4 @@
-require 'active_support/benchmarkable'
+require "active_support/benchmarkable"
module ActionView #:nodoc:
module Helpers #:nodoc:
diff --git a/actionview/lib/action_view/helpers/active_model_helper.rb b/actionview/lib/action_view/helpers/active_model_helper.rb
index d5222e3616..4bb5788a16 100644
--- a/actionview/lib/action_view/helpers/active_model_helper.rb
+++ b/actionview/lib/action_view/helpers/active_model_helper.rb
@@ -1,5 +1,5 @@
-require 'active_support/core_ext/module/attribute_accessors'
-require 'active_support/core_ext/enumerable'
+require "active_support/core_ext/module/attribute_accessors"
+require "active_support/core_ext/enumerable"
module ActionView
# = Active Model Helpers
@@ -37,13 +37,13 @@ module ActionView
private
- def object_has_errors?
- object.respond_to?(:errors) && object.errors.respond_to?(:[]) && error_message.present?
- end
+ def object_has_errors?
+ object.respond_to?(:errors) && object.errors.respond_to?(:[]) && error_message.present?
+ end
- def tag_generate_errors?(options)
- options['type'] != 'hidden'
- end
+ def tag_generate_errors?(options)
+ options["type"] != "hidden"
+ end
end
end
end
diff --git a/actionview/lib/action_view/helpers/asset_tag_helper.rb b/actionview/lib/action_view/helpers/asset_tag_helper.rb
index d7acf08b45..6cac4bc0ad 100644
--- a/actionview/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionview/lib/action_view/helpers/asset_tag_helper.rb
@@ -1,8 +1,8 @@
-require 'active_support/core_ext/array/extract_options'
-require 'active_support/core_ext/hash/keys'
-require 'active_support/core_ext/regexp'
-require 'action_view/helpers/asset_url_helper'
-require 'action_view/helpers/tag_helper'
+require "active_support/core_ext/array/extract_options"
+require "active_support/core_ext/hash/keys"
+require "active_support/core_ext/regexp"
+require "action_view/helpers/asset_url_helper"
+require "action_view/helpers/tag_helper"
module ActionView
# = Action View Asset Tag Helpers
@@ -56,7 +56,7 @@ module ActionView
# # => <script src="http://www.example.com/xmlhr.js"></script>
def javascript_include_tag(*sources)
options = sources.extract_options!.stringify_keys
- path_options = options.extract!('protocol', 'extname', 'host').symbolize_keys
+ path_options = options.extract!("protocol", "extname", "host").symbolize_keys
sources.uniq.map { |source|
tag_options = {
"src" => path_to_javascript(source, path_options)
@@ -92,7 +92,7 @@ module ActionView
# # <link href="/css/stylish.css" media="screen" rel="stylesheet" />
def stylesheet_link_tag(*sources)
options = sources.extract_options!.stringify_keys
- path_options = options.extract!('protocol', 'host').symbolize_keys
+ path_options = options.extract!("protocol", "host").symbolize_keys
sources.uniq.map { |source|
tag_options = {
@@ -139,7 +139,7 @@ module ActionView
"rel" => tag_options[:rel] || "alternate",
"type" => tag_options[:type] || Template::Types[type].to_s,
"title" => tag_options[:title] || type.to_s.upcase,
- "href" => url_options.is_a?(Hash) ? url_for(url_options.merge(:only_path => false)) : url_options
+ "href" => url_options.is_a?(Hash) ? url_for(url_options.merge(only_path: false)) : url_options
)
end
@@ -170,11 +170,11 @@ module ActionView
#
# favicon_link_tag 'mb-icon.png', rel: 'apple-touch-icon', type: 'image/png'
# # => <link href="/assets/mb-icon.png" rel="apple-touch-icon" type="image/png" />
- def favicon_link_tag(source='favicon.ico', options={})
- tag('link', {
- :rel => 'shortcut icon',
- :type => 'image/x-icon',
- :href => path_to_image(source)
+ def favicon_link_tag(source="favicon.ico", options={})
+ tag("link", {
+ rel: "shortcut icon",
+ type: "image/x-icon",
+ href: path_to_image(source)
}.merge!(options.symbolize_keys))
end
@@ -214,7 +214,7 @@ module ActionView
src = options[:src] = path_to_image(source)
- unless src.start_with?('cid:') || src.start_with?('data:') || src.blank?
+ unless src.start_with?("cid:") || src.start_with?("data:") || src.blank?
options[:alt] = options.fetch(:alt) { image_alt(src) }
end
@@ -240,7 +240,7 @@ module ActionView
# image_alt('underscored_file_name.png')
# # => Underscored file name
def image_alt(src)
- File.basename(src, '.*'.freeze).sub(/-[[:xdigit:]]{32,64}\z/, ''.freeze).tr('-_'.freeze, ' '.freeze).capitalize
+ File.basename(src, ".*".freeze).sub(/-[[:xdigit:]]{32,64}\z/, "".freeze).tr("-_".freeze, " ".freeze).capitalize
end
# Returns an HTML video tag for the +sources+. If +sources+ is a string,
@@ -282,7 +282,7 @@ module ActionView
# video_tag(["trailer.ogg", "trailer.flv"], size: "160x120")
# # => <video height="120" width="160"><source src="/videos/trailer.ogg" /><source src="/videos/trailer.flv" /></video>
def video_tag(*sources)
- multiple_sources_tag('video', sources) do |options|
+ multiple_sources_tag("video", sources) do |options|
options[:poster] = path_to_image(options[:poster]) if options[:poster]
options[:width], options[:height] = extract_dimensions(options.delete(:size)) if options[:size]
end
@@ -301,7 +301,7 @@ module ActionView
# audio_tag("sound.wav", "sound.mid")
# # => <audio><source src="/audios/sound.wav" /><source src="/audios/sound.mid" /></audio>
def audio_tag(*sources)
- multiple_sources_tag('audio', sources)
+ multiple_sources_tag("audio", sources)
end
private
@@ -313,7 +313,7 @@ module ActionView
if sources.size > 1
content_tag(type, options) do
- safe_join sources.map { |source| tag("source", :src => send("path_to_#{type}", source)) }
+ safe_join sources.map { |source| tag("source", src: send("path_to_#{type}", source)) }
end
else
options[:src] = send("path_to_#{type}", sources.first)
@@ -324,7 +324,7 @@ module ActionView
def extract_dimensions(size)
size = size.to_s
if /\A\d+x\d+\z/.match?(size)
- size.split('x')
+ size.split("x")
elsif /\A\d+\z/.match?(size)
[size, size]
end
diff --git a/actionview/lib/action_view/helpers/asset_url_helper.rb b/actionview/lib/action_view/helpers/asset_url_helper.rb
index 8af01617fa..7bd3027880 100644
--- a/actionview/lib/action_view/helpers/asset_url_helper.rb
+++ b/actionview/lib/action_view/helpers/asset_url_helper.rb
@@ -1,5 +1,5 @@
-require 'zlib'
-require 'active_support/core_ext/regexp'
+require "zlib"
+require "active_support/core_ext/regexp"
module ActionView
# = Action View Asset URL Helpers
@@ -132,10 +132,10 @@ module ActionView
raise ArgumentError, "nil is not a valid asset source" if source.nil?
source = source.to_s
- return '' if source.blank?
+ return "" if source.blank?
return source if URI_REGEXP.match?(source)
- tail, source = source[/([\?#].+)$/], source.sub(/([\?#].+)$/, ''.freeze)
+ tail, source = source[/([\?#].+)$/], source.sub(/([\?#].+)$/, "".freeze)
if extname = compute_asset_extname(source, options)
source = "#{source}#{extname}"
@@ -169,13 +169,13 @@ module ActionView
# asset_url "application.js", host: "http://cdn.example.com" # => http://cdn.example.com/assets/application.js
#
def asset_url(source, options = {})
- path_to_asset(source, options.merge(:protocol => :request))
+ path_to_asset(source, options.merge(protocol: :request))
end
alias_method :url_to_asset, :asset_url # aliased to avoid conflicts with an asset_url named route
ASSET_EXTENSIONS = {
- javascript: '.js',
- stylesheet: '.css'
+ javascript: ".js",
+ stylesheet: ".css"
}
# Compute extname to append to asset path. Returns nil if
@@ -188,12 +188,12 @@ module ActionView
# Maps asset types to public directory.
ASSET_PUBLIC_DIRECTORIES = {
- audio: '/audios',
- font: '/fonts',
- image: '/images',
- javascript: '/javascripts',
- stylesheet: '/stylesheets',
- video: '/videos'
+ audio: "/audios",
+ font: "/fonts",
+ image: "/images",
+ javascript: "/javascripts",
+ stylesheet: "/stylesheets",
+ video: "/videos"
}
# Computes asset path to public directory. Plugins and
@@ -220,7 +220,7 @@ module ActionView
args = [source]
args << request if request && (arity > 1 || arity < 0)
host = host.call(*args)
- elsif host.include?('%d')
+ elsif host.include?("%d")
host = host % (Zlib.crc32(source) % 4)
end
end
diff --git a/actionview/lib/action_view/helpers/atom_feed_helper.rb b/actionview/lib/action_view/helpers/atom_feed_helper.rb
index c875f5870f..e5d063e03c 100644
--- a/actionview/lib/action_view/helpers/atom_feed_helper.rb
+++ b/actionview/lib/action_view/helpers/atom_feed_helper.rb
@@ -1,4 +1,4 @@
-require 'set'
+require "set"
module ActionView
# = Action View Atom Feed Helpers
@@ -112,13 +112,13 @@ module ActionView
end
end
- feed_opts = {"xml:lang" => options[:language] || "en-US", "xmlns" => 'http://www.w3.org/2005/Atom'}
+ feed_opts = {"xml:lang" => options[:language] || "en-US", "xmlns" => "http://www.w3.org/2005/Atom"}
feed_opts.merge!(options).reject!{|k,v| !k.to_s.match(/^xml/)}
xml.feed(feed_opts) do
xml.id(options[:id] || "tag:#{request.host},#{options[:schema_date]}:#{request.fullpath.split(".")[0]}")
- xml.link(:rel => 'alternate', :type => 'text/html', :href => options[:root_url] || (request.protocol + request.host_with_port))
- xml.link(:rel => 'self', :type => 'application/atom+xml', :href => options[:url] || request.url)
+ xml.link(rel: "alternate", type: "text/html", href: options[:root_url] || (request.protocol + request.host_with_port))
+ xml.link(rel: "self", type: "application/atom+xml", href: options[:url] || request.url)
yield AtomFeedBuilder.new(xml, self, options)
end
@@ -138,7 +138,7 @@ module ActionView
def method_missing(method, *arguments, &block)
if xhtml_block?(method, arguments)
@xml.__send__(method, *arguments) do
- @xml.div(:xmlns => 'http://www.w3.org/1999/xhtml') do |xhtml|
+ @xml.div(xmlns: "http://www.w3.org/1999/xhtml") do |xhtml|
block.call(xhtml)
end
end
@@ -153,7 +153,7 @@ module ActionView
def xhtml_block?(method, arguments)
if XHTML_TAG_NAMES.include?(method.to_s)
last = arguments.last
- last.is_a?(Hash) && last[:type].to_s == 'xhtml'
+ last.is_a?(Hash) && last[:type].to_s == "xhtml"
end
end
end
@@ -189,16 +189,15 @@ module ActionView
@xml.updated((options[:updated] || record.updated_at).xmlschema)
end
- type = options.fetch(:type, 'text/html')
+ type = options.fetch(:type, "text/html")
url = options.fetch(:url) { @view.polymorphic_url(record) }
- @xml.link(:rel => 'alternate', :type => type, :href => url) if url
+ @xml.link(rel: "alternate", type: type, href: url) if url
yield AtomBuilder.new(@xml)
end
end
end
-
end
end
end
diff --git a/actionview/lib/action_view/helpers/capture_helper.rb b/actionview/lib/action_view/helpers/capture_helper.rb
index df8d0affd0..5b569b5923 100644
--- a/actionview/lib/action_view/helpers/capture_helper.rb
+++ b/actionview/lib/action_view/helpers/capture_helper.rb
@@ -1,4 +1,4 @@
-require 'active_support/core_ext/string/output_safety'
+require "active_support/core_ext/string/output_safety"
module ActionView
# = Action View Capture Helper
diff --git a/actionview/lib/action_view/helpers/controller_helper.rb b/actionview/lib/action_view/helpers/controller_helper.rb
index 3569fba8c6..e86cdca4e4 100644
--- a/actionview/lib/action_view/helpers/controller_helper.rb
+++ b/actionview/lib/action_view/helpers/controller_helper.rb
@@ -1,4 +1,4 @@
-require 'active_support/core_ext/module/attr_internal'
+require "active_support/core_ext/module/attr_internal"
module ActionView
module Helpers
@@ -8,7 +8,7 @@ module ActionView
attr_internal :controller, :request
delegate :request_forgery_protection_token, :params, :session, :cookies, :response, :headers,
- :flash, :action_name, :controller_name, :controller_path, :to => :controller
+ :flash, :action_name, :controller_name, :controller_path, to: :controller
def assign_controller(controller)
if @_controller = controller
diff --git a/actionview/lib/action_view/helpers/csrf_helper.rb b/actionview/lib/action_view/helpers/csrf_helper.rb
index 5af92c4ff2..2a15d2aa5a 100644
--- a/actionview/lib/action_view/helpers/csrf_helper.rb
+++ b/actionview/lib/action_view/helpers/csrf_helper.rb
@@ -14,14 +14,14 @@ module ActionView
#
# You don't need to use these tags for regular forms as they generate their own hidden fields.
#
- # For AJAX requests other than GETs, extract the "csrf-token" from the meta-tag and send as the
+ # For AJAX requests other than GETs, extract the "csrf-token" from the meta-tag and send as the
# "X-CSRF-Token" HTTP header. If you are using jQuery with jquery-rails this happens automatically.
#
def csrf_meta_tags
if protect_against_forgery?
[
- tag('meta', :name => 'csrf-param', :content => request_forgery_protection_token),
- tag('meta', :name => 'csrf-token', :content => form_authenticity_token)
+ tag("meta", name: "csrf-param", content: request_forgery_protection_token),
+ tag("meta", name: "csrf-token", content: form_authenticity_token)
].join("\n").html_safe
end
end
diff --git a/actionview/lib/action_view/helpers/date_helper.rb b/actionview/lib/action_view/helpers/date_helper.rb
index a02702bf7a..99db209d63 100644
--- a/actionview/lib/action_view/helpers/date_helper.rb
+++ b/actionview/lib/action_view/helpers/date_helper.rb
@@ -1,10 +1,10 @@
-require 'date'
-require 'action_view/helpers/tag_helper'
-require 'active_support/core_ext/array/extract_options'
-require 'active_support/core_ext/date/conversions'
-require 'active_support/core_ext/hash/slice'
-require 'active_support/core_ext/object/acts_like'
-require 'active_support/core_ext/object/with_options'
+require "date"
+require "action_view/helpers/tag_helper"
+require "active_support/core_ext/array/extract_options"
+require "active_support/core_ext/date/conversions"
+require "active_support/core_ext/hash/slice"
+require "active_support/core_ext/object/acts_like"
+require "active_support/core_ext/object/with_options"
module ActionView
module Helpers
@@ -101,60 +101,60 @@ module ActionView
distance_in_minutes = ((to_time - from_time)/60.0).round
distance_in_seconds = (to_time - from_time).round
- I18n.with_options :locale => options[:locale], :scope => options[:scope] do |locale|
+ I18n.with_options locale: options[:locale], scope: options[:scope] do |locale|
case distance_in_minutes
- when 0..1
- return distance_in_minutes == 0 ?
- locale.t(:less_than_x_minutes, :count => 1) :
- locale.t(:x_minutes, :count => distance_in_minutes) unless options[:include_seconds]
-
- case distance_in_seconds
- when 0..4 then locale.t :less_than_x_seconds, :count => 5
- when 5..9 then locale.t :less_than_x_seconds, :count => 10
- when 10..19 then locale.t :less_than_x_seconds, :count => 20
- when 20..39 then locale.t :half_a_minute
- when 40..59 then locale.t :less_than_x_minutes, :count => 1
- else locale.t :x_minutes, :count => 1
- end
-
- when 2...45 then locale.t :x_minutes, :count => distance_in_minutes
- when 45...90 then locale.t :about_x_hours, :count => 1
+ when 0..1
+ return distance_in_minutes == 0 ?
+ locale.t(:less_than_x_minutes, count: 1) :
+ locale.t(:x_minutes, count: distance_in_minutes) unless options[:include_seconds]
+
+ case distance_in_seconds
+ when 0..4 then locale.t :less_than_x_seconds, count: 5
+ when 5..9 then locale.t :less_than_x_seconds, count: 10
+ when 10..19 then locale.t :less_than_x_seconds, count: 20
+ when 20..39 then locale.t :half_a_minute
+ when 40..59 then locale.t :less_than_x_minutes, count: 1
+ else locale.t :x_minutes, count: 1
+ end
+
+ when 2...45 then locale.t :x_minutes, count: distance_in_minutes
+ when 45...90 then locale.t :about_x_hours, count: 1
# 90 mins up to 24 hours
- when 90...1440 then locale.t :about_x_hours, :count => (distance_in_minutes.to_f / 60.0).round
+ when 90...1440 then locale.t :about_x_hours, count: (distance_in_minutes.to_f / 60.0).round
# 24 hours up to 42 hours
- when 1440...2520 then locale.t :x_days, :count => 1
+ when 1440...2520 then locale.t :x_days, count: 1
# 42 hours up to 30 days
- when 2520...43200 then locale.t :x_days, :count => (distance_in_minutes.to_f / 1440.0).round
+ when 2520...43200 then locale.t :x_days, count: (distance_in_minutes.to_f / 1440.0).round
# 30 days up to 60 days
- when 43200...86400 then locale.t :about_x_months, :count => (distance_in_minutes.to_f / 43200.0).round
+ when 43200...86400 then locale.t :about_x_months, count: (distance_in_minutes.to_f / 43200.0).round
# 60 days up to 365 days
- when 86400...525600 then locale.t :x_months, :count => (distance_in_minutes.to_f / 43200.0).round
+ when 86400...525600 then locale.t :x_months, count: (distance_in_minutes.to_f / 43200.0).round
+ else
+ if from_time.acts_like?(:time) && to_time.acts_like?(:time)
+ fyear = from_time.year
+ fyear += 1 if from_time.month >= 3
+ tyear = to_time.year
+ tyear -= 1 if to_time.month < 3
+ leap_years = (fyear > tyear) ? 0 : (fyear..tyear).count{|x| Date.leap?(x)}
+ minute_offset_for_leap_year = leap_years * 1440
+ # Discount the leap year days when calculating year distance.
+ # e.g. if there are 20 leap year days between 2 dates having the same day
+ # and month then the based on 365 days calculation
+ # the distance in years will come out to over 80 years when in written
+ # English it would read better as about 80 years.
+ minutes_with_offset = distance_in_minutes - minute_offset_for_leap_year
else
- if from_time.acts_like?(:time) && to_time.acts_like?(:time)
- fyear = from_time.year
- fyear += 1 if from_time.month >= 3
- tyear = to_time.year
- tyear -= 1 if to_time.month < 3
- leap_years = (fyear > tyear) ? 0 : (fyear..tyear).count{|x| Date.leap?(x)}
- minute_offset_for_leap_year = leap_years * 1440
- # Discount the leap year days when calculating year distance.
- # e.g. if there are 20 leap year days between 2 dates having the same day
- # and month then the based on 365 days calculation
- # the distance in years will come out to over 80 years when in written
- # English it would read better as about 80 years.
- minutes_with_offset = distance_in_minutes - minute_offset_for_leap_year
- else
- minutes_with_offset = distance_in_minutes
- end
- remainder = (minutes_with_offset % MINUTES_IN_YEAR)
- distance_in_years = (minutes_with_offset.div MINUTES_IN_YEAR)
- if remainder < MINUTES_IN_QUARTER_YEAR
- locale.t(:about_x_years, :count => distance_in_years)
- elsif remainder < MINUTES_IN_THREE_QUARTERS_YEAR
- locale.t(:over_x_years, :count => distance_in_years)
- else
- locale.t(:almost_x_years, :count => distance_in_years + 1)
- end
+ minutes_with_offset = distance_in_minutes
+ end
+ remainder = (minutes_with_offset % MINUTES_IN_YEAR)
+ distance_in_years = (minutes_with_offset.div MINUTES_IN_YEAR)
+ if remainder < MINUTES_IN_QUARTER_YEAR
+ locale.t(:about_x_years, count: distance_in_years)
+ elsif remainder < MINUTES_IN_THREE_QUARTERS_YEAR
+ locale.t(:over_x_years, count: distance_in_years)
+ else
+ locale.t(:almost_x_years, count: distance_in_years + 1)
+ end
end
end
end
@@ -682,19 +682,19 @@ module ActionView
def time_tag(date_or_time, *args, &block)
options = args.extract_options!
format = options.delete(:format) || :long
- content = args.first || I18n.l(date_or_time, :format => format)
+ content = args.first || I18n.l(date_or_time, format: format)
datetime = date_or_time.acts_like?(:time) ? date_or_time.xmlschema : date_or_time.iso8601
- content_tag("time".freeze, content, options.reverse_merge(:datetime => datetime), &block)
+ content_tag("time".freeze, content, options.reverse_merge(datetime: datetime), &block)
end
end
class DateTimeSelector #:nodoc:
include ActionView::Helpers::TagHelper
- DEFAULT_PREFIX = 'date'.freeze
+ DEFAULT_PREFIX = "date".freeze
POSITION = {
- :year => 1, :month => 2, :day => 3, :hour => 4, :minute => 5, :second => 6
+ year: 1, month: 2, day: 3, hour: 4, minute: 5, second: 6
}.freeze
AMPM_TRANSLATION = Hash[
@@ -710,8 +710,8 @@ module ActionView
@options = options.dup
@html_options = html_options.dup
@datetime = datetime
- @options[:datetime_separator] ||= ' &mdash; '
- @options[:time_separator] ||= ' : '
+ @options[:datetime_separator] ||= " &mdash; "
+ @options[:time_separator] ||= " : "
end
def select_datetime
@@ -781,7 +781,7 @@ module ActionView
if @options[:use_hidden] || @options[:discard_minute]
build_hidden(:minute, min)
else
- build_options_and_select(:minute, min, :step => @options[:minute_step])
+ build_options_and_select(:minute, min, step: @options[:minute_step])
end
end
@@ -801,7 +801,7 @@ module ActionView
if @options[:use_hidden] || @options[:discard_day]
build_hidden(:day, day || 1)
else
- build_options_and_select(:day, day, :start => 1, :end => 31, :leading_zeros => false, :use_two_digit_numbers => @options[:use_two_digit_numbers])
+ build_options_and_select(:day, day, start: 1, end: 31, leading_zeros: false, use_two_digit_numbers: @options[:use_two_digit_numbers])
end
end
@@ -811,7 +811,7 @@ module ActionView
else
month_options = []
1.upto(12) do |month_number|
- options = { :value => month_number }
+ options = { value: month_number }
options[:selected] = "selected" if month == month_number
month_options << content_tag("option".freeze, month_name(month_number), options) + "\n"
end
@@ -821,7 +821,7 @@ module ActionView
def select_year
if !@datetime || @datetime == 0
- val = '1'
+ val = "1"
middle_year = Date.today.year
else
val = middle_year = year
@@ -861,7 +861,7 @@ module ActionView
# valid. Otherwise, February 31st or February 29th, 2011 can be selected, which are invalid.
def set_day_if_discarded
if @datetime && @options[:discard_day]
- @datetime = @datetime.change(:day => 1)
+ @datetime = @datetime.change(day: 1)
end
end
@@ -886,7 +886,7 @@ module ActionView
# "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
def translated_month_names
key = @options[:use_short_month] ? :'date.abbr_month_names' : :'date.month_names'
- I18n.translate(key, :locale => @options[:locale])
+ I18n.translate(key, locale: @options[:locale])
end
# Looks up month names by number (1-based):
@@ -914,7 +914,7 @@ module ActionView
if @options[:use_month_numbers]
number
elsif @options[:use_two_digit_numbers]
- '%02d' % number
+ "%02d" % number
elsif @options[:add_month_numbers]
"#{number} - #{month_names[number]}"
elsif format_string = @options[:month_format_string]
@@ -929,7 +929,7 @@ module ActionView
end
def translated_date_order
- date_order = I18n.translate(:'date.order', :locale => @options[:locale], :default => [])
+ date_order = I18n.translate(:'date.order', locale: @options[:locale], default: [])
date_order = date_order.map(&:to_sym)
forbidden_elements = date_order - [:year, :month, :day]
@@ -976,7 +976,7 @@ module ActionView
select_options = []
start.step(stop, step) do |i|
value = leading_zeros ? sprintf("%02d", i) : i
- tag_options = { :value => value }
+ tag_options = { value: value }
tag_options[:selected] = "selected" if selected == i
text = options[:use_two_digit_numbers] ? sprintf("%02d", i) : value
text = options[:ampm] ? AMPM_TRANSLATION[i] : text
@@ -993,14 +993,14 @@ module ActionView
# </select>"
def build_select(type, select_options_as_html)
select_options = {
- :id => input_id_from_type(type),
- :name => input_name_from_type(type)
+ id: input_id_from_type(type),
+ name: input_name_from_type(type)
}.merge!(@html_options)
- select_options[:disabled] = 'disabled' if @options[:disabled]
+ select_options[:disabled] = "disabled" if @options[:disabled]
select_options[:class] = css_class_attribute(type, select_options[:class], @options[:with_css_classes]) if @options[:with_css_classes]
select_html = "\n"
- select_html << content_tag("option".freeze, '', :value => '') + "\n" if @options[:include_blank]
+ select_html << content_tag("option".freeze, "", value: "") + "\n" if @options[:include_blank]
select_html << prompt_option_tag(type, @options[:prompt]) + "\n" if @options[:prompt]
select_html << select_options_as_html
@@ -1018,7 +1018,7 @@ module ActionView
type
end
- [html_options_class, css_class].compact.join(' ')
+ [html_options_class, css_class].compact.join(" ")
end
# Builds a prompt option tag with supplied options or from default options.
@@ -1026,16 +1026,16 @@ module ActionView
# => "<option value="">Select month</option>"
def prompt_option_tag(type, options)
prompt = case options
- when Hash
- default_options = {:year => false, :month => false, :day => false, :hour => false, :minute => false, :second => false}
- default_options.merge!(options)[type.to_sym]
- when String
- options
+ when Hash
+ default_options = {year: false, month: false, day: false, hour: false, minute: false, second: false}
+ default_options.merge!(options)[type.to_sym]
+ when String
+ options
else
- I18n.translate(:"datetime.prompts.#{type}", :locale => @options[:locale])
+ I18n.translate(:"datetime.prompts.#{type}", locale: @options[:locale])
end
- prompt ? content_tag("option".freeze, prompt, :value => '') : ''
+ prompt ? content_tag("option".freeze, prompt, value: "") : ""
end
# Builds hidden input tag for date part and value.
@@ -1043,12 +1043,12 @@ module ActionView
# => "<input id="post_written_on_1i" name="post[written_on(1i)]" type="hidden" value="2008" />"
def build_hidden(type, value)
select_options = {
- :type => "hidden",
- :id => input_id_from_type(type),
- :name => input_name_from_type(type),
- :value => value
+ type: "hidden",
+ id: input_id_from_type(type),
+ name: input_name_from_type(type),
+ value: value
}.merge!(@html_options.slice(:disabled))
- select_options[:disabled] = 'disabled' if @options[:disabled]
+ select_options[:disabled] = "disabled" if @options[:disabled]
tag(:input, select_options) + "\n".html_safe
end
@@ -1070,8 +1070,8 @@ module ActionView
# Returns the id attribute for the input tag.
# => "post_written_on_1i"
def input_id_from_type(type)
- id = input_name_from_type(type).gsub(/([\[\(])|(\]\[)/, '_').gsub(/[\]\)]/, '')
- id = @options[:namespace] + '_' + id if @options[:namespace]
+ id = input_name_from_type(type).gsub(/([\[\(])|(\]\[)/, "_").gsub(/[\]\)]/, "")
+ id = @options[:namespace] + "_" + id if @options[:namespace]
id
end
@@ -1079,7 +1079,7 @@ module ActionView
# Given an ordering of datetime components, create the selection HTML
# and join them with their appropriate separators.
def build_selects_from_types(order)
- select = ''
+ select = ""
first_visible = order.find { |type| !@options[:"discard_#{type}"] }
order.reverse_each do |type|
separator = separator(type) unless type == first_visible # don't add before first visible field
@@ -1093,12 +1093,12 @@ module ActionView
return "" if @options[:use_hidden]
case type
- when :year, :month, :day
- @options[:"discard_#{type}"] ? "" : @options[:date_separator]
- when :hour
- (@options[:discard_year] && @options[:discard_day]) ? "" : @options[:datetime_separator]
- when :minute, :second
- @options[:"discard_#{type}"] ? "" : @options[:time_separator]
+ when :year, :month, :day
+ @options[:"discard_#{type}"] ? "" : @options[:date_separator]
+ when :hour
+ (@options[:discard_year] && @options[:discard_day]) ? "" : @options[:datetime_separator]
+ when :minute, :second
+ @options[:"discard_#{type}"] ? "" : @options[:time_separator]
end
end
end
diff --git a/actionview/lib/action_view/helpers/debug_helper.rb b/actionview/lib/action_view/helpers/debug_helper.rb
index e9dccbad1c..f61ca2c9c2 100644
--- a/actionview/lib/action_view/helpers/debug_helper.rb
+++ b/actionview/lib/action_view/helpers/debug_helper.rb
@@ -4,7 +4,6 @@ module ActionView
# Provides a set of methods for making it easier to debug Rails objects.
module Helpers
module DebugHelper
-
include TagHelper
# Returns a YAML representation of +object+ wrapped with <pre> and </pre>.
@@ -25,10 +24,10 @@ module ActionView
def debug(object)
Marshal::dump(object)
object = ERB::Util.html_escape(object.to_yaml)
- content_tag(:pre, object, :class => "debug_dump")
+ content_tag(:pre, object, class: "debug_dump")
rescue # errors from Marshal or YAML
# Object couldn't be dumped, perhaps because of singleton methods -- this is the fallback
- content_tag(:code, object.inspect, :class => "debug_dump")
+ content_tag(:code, object.inspect, class: "debug_dump")
end
end
end
diff --git a/actionview/lib/action_view/helpers/form_helper.rb b/actionview/lib/action_view/helpers/form_helper.rb
index 3d2ae0cfe0..f470375988 100644
--- a/actionview/lib/action_view/helpers/form_helper.rb
+++ b/actionview/lib/action_view/helpers/form_helper.rb
@@ -1,14 +1,14 @@
-require 'cgi'
-require 'action_view/helpers/date_helper'
-require 'action_view/helpers/tag_helper'
-require 'action_view/helpers/form_tag_helper'
-require 'action_view/helpers/active_model_helper'
-require 'action_view/model_naming'
-require 'action_view/record_identifier'
-require 'active_support/core_ext/module/attribute_accessors'
-require 'active_support/core_ext/hash/slice'
-require 'active_support/core_ext/string/output_safety'
-require 'active_support/core_ext/string/inflections'
+require "cgi"
+require "action_view/helpers/date_helper"
+require "action_view/helpers/tag_helper"
+require "action_view/helpers/form_tag_helper"
+require "action_view/helpers/active_model_helper"
+require "action_view/model_naming"
+require "action_view/record_identifier"
+require "active_support/core_ext/module/attribute_accessors"
+require "active_support/core_ext/hash/slice"
+require "active_support/core_ext/string/output_safety"
+require "active_support/core_ext/string/inflections"
module ActionView
# = Action View Form Helpers
@@ -467,7 +467,7 @@ module ActionView
)
options[:url] ||= if options.key?(:format)
- polymorphic_path(record, format: options.delete(:format))
+ polymorphic_path(record, format: options.delete(:format))
else
polymorphic_path(record, {})
end
@@ -1270,7 +1270,7 @@ module ActionView
end
def self._to_partial_path
- @_to_partial_path ||= name.demodulize.underscore.sub!(/_builder$/, '')
+ @_to_partial_path ||= name.demodulize.underscore.sub!(/_builder$/, "")
end
def to_partial_path
@@ -1573,8 +1573,8 @@ module ActionView
end
record_name = if index
- "#{object_name}[#{index}][#{record_name}]"
- elsif record_name.to_s.end_with?('[]')
+ "#{object_name}[#{index}][#{record_name}]"
+ elsif record_name.to_s.end_with?("[]")
record_name = record_name.to_s.sub(/(.*)\[\]$/, "[\\1][#{record_object.id}]")
"#{object_name}#{record_name}"
else
diff --git a/actionview/lib/action_view/helpers/form_options_helper.rb b/actionview/lib/action_view/helpers/form_options_helper.rb
index 0cd3207b12..07d4310a4e 100644
--- a/actionview/lib/action_view/helpers/form_options_helper.rb
+++ b/actionview/lib/action_view/helpers/form_options_helper.rb
@@ -1,9 +1,9 @@
-require 'cgi'
-require 'erb'
-require 'action_view/helpers/form_helper'
-require 'active_support/core_ext/string/output_safety'
-require 'active_support/core_ext/array/extract_options'
-require 'active_support/core_ext/array/wrap'
+require "cgi"
+require "erb"
+require "action_view/helpers/form_helper"
+require "active_support/core_ext/string/output_safety"
+require "active_support/core_ext/array/extract_options"
+require "active_support/core_ext/array/wrap"
module ActionView
# = Action View Form Option Helpers
@@ -578,7 +578,7 @@ module ActionView
end
zone_options.safe_concat options_for_select(convert_zones[priority_zones], selected)
- zone_options.safe_concat content_tag("option".freeze, '-------------', value: '', disabled: true)
+ zone_options.safe_concat content_tag("option".freeze, "-------------", value: "", disabled: true)
zone_options.safe_concat "\n"
zones = zones - priority_zones
@@ -800,7 +800,7 @@ module ActionView
end
def prompt_text(prompt)
- prompt.kind_of?(String) ? prompt : I18n.translate('helpers.select.prompt', default: 'Please select')
+ prompt.kind_of?(String) ? prompt : I18n.translate("helpers.select.prompt", default: "Please select")
end
end
diff --git a/actionview/lib/action_view/helpers/form_tag_helper.rb b/actionview/lib/action_view/helpers/form_tag_helper.rb
index f1375570f2..a8abe6b7c4 100644
--- a/actionview/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionview/lib/action_view/helpers/form_tag_helper.rb
@@ -1,7 +1,7 @@
-require 'cgi'
-require 'action_view/helpers/tag_helper'
-require 'active_support/core_ext/string/output_safety'
-require 'active_support/core_ext/module/attribute_accessors'
+require "cgi"
+require "action_view/helpers/tag_helper"
+require "active_support/core_ext/string/output_safety"
+require "active_support/core_ext/module/attribute_accessors"
module ActionView
# = Action View Form Tag Helpers
@@ -134,11 +134,11 @@ module ActionView
if options.include?(:include_blank)
include_blank = options.delete(:include_blank)
- options_for_blank_options_tag = { value: '' }
+ options_for_blank_options_tag = { value: "" }
if include_blank == true
- include_blank = ''
- options_for_blank_options_tag[:label] = ' '
+ include_blank = ""
+ options_for_blank_options_tag[:label] = " "
end
if include_blank
@@ -147,7 +147,7 @@ module ActionView
end
if prompt = options.delete(:prompt)
- option_tags = content_tag("option".freeze, prompt, value: '').safe_concat(option_tags)
+ option_tags = content_tag("option".freeze, prompt, value: "").safe_concat(option_tags)
end
content_tag "select".freeze, option_tags, { "name" => html_name, "id" => sanitize_to_id(name) }.update(options.stringify_keys)
@@ -518,12 +518,12 @@ module ActionView
options ||= {}
end
- options = { 'name' => 'button', 'type' => 'submit' }.merge!(options.stringify_keys)
+ options = { "name" => "button", "type" => "submit" }.merge!(options.stringify_keys)
if block_given?
content_tag :button, options, &block
else
- content_tag :button, content_or_options || 'Button', options
+ content_tag :button, content_or_options || "Button", options
end
end
@@ -693,7 +693,7 @@ module ActionView
# * <tt>:step</tt> - The acceptable value granularity.
# * Otherwise accepts the same options as text_field_tag.
def datetime_field_tag(name, value = nil, options = {})
- text_field_tag(name, value, options.merge(type: 'datetime-local'))
+ text_field_tag(name, value, options.merge(type: "datetime-local"))
end
alias datetime_local_field_tag datetime_field_tag
@@ -858,21 +858,21 @@ module ActionView
method = html_options.delete("method").to_s.downcase
method_tag = case method
- when 'get'
- html_options["method"] = "get"
- ''
- when 'post', ''
- html_options["method"] = "post"
- token_tag(authenticity_token, form_options: {
- action: html_options["action"],
- method: "post"
- })
+ when "get"
+ html_options["method"] = "get"
+ ""
+ when "post", ""
+ html_options["method"] = "post"
+ token_tag(authenticity_token, form_options: {
+ action: html_options["action"],
+ method: "post"
+ })
else
- html_options["method"] = "post"
- method_tag(method) + token_tag(authenticity_token, form_options: {
- action: html_options["action"],
- method: method
- })
+ html_options["method"] = "post"
+ method_tag(method) + token_tag(authenticity_token, form_options: {
+ action: html_options["action"],
+ method: method
+ })
end
if html_options.delete("enforce_utf8") { true }
@@ -895,7 +895,7 @@ module ActionView
# see http://www.w3.org/TR/html4/types.html#type-name
def sanitize_to_id(name)
- name.to_s.delete(']').tr('^-a-zA-Z0-9:.', "_")
+ name.to_s.delete("]").tr("^-a-zA-Z0-9:.", "_")
end
end
end
diff --git a/actionview/lib/action_view/helpers/javascript_helper.rb b/actionview/lib/action_view/helpers/javascript_helper.rb
index ed7e882c94..8f7be4905d 100644
--- a/actionview/lib/action_view/helpers/javascript_helper.rb
+++ b/actionview/lib/action_view/helpers/javascript_helper.rb
@@ -1,11 +1,11 @@
-require 'action_view/helpers/tag_helper'
+require "action_view/helpers/tag_helper"
module ActionView
module Helpers
module JavaScriptHelper
JS_ESCAPE_MAP = {
'\\' => '\\\\',
- '</' => '<\/',
+ "</" => '<\/',
"\r\n" => '\n',
"\n" => '\n',
"\r" => '\n',
@@ -13,8 +13,8 @@ module ActionView
"'" => "\\'"
}
- JS_ESCAPE_MAP["\342\200\250".force_encoding(Encoding::UTF_8).encode!] = '&#x2028;'
- JS_ESCAPE_MAP["\342\200\251".force_encoding(Encoding::UTF_8).encode!] = '&#x2029;'
+ JS_ESCAPE_MAP["\342\200\250".force_encoding(Encoding::UTF_8).encode!] = "&#x2028;"
+ JS_ESCAPE_MAP["\342\200\251".force_encoding(Encoding::UTF_8).encode!] = "&#x2029;"
# Escapes carriage returns and single and double quotes for JavaScript segments.
#
@@ -27,7 +27,7 @@ module ActionView
result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"'])/u) {|match| JS_ESCAPE_MAP[match] }
javascript.html_safe? ? result.html_safe : result
else
- ''
+ ""
end
end
diff --git a/actionview/lib/action_view/helpers/number_helper.rb b/actionview/lib/action_view/helpers/number_helper.rb
index 23081c5f07..75b898c3e9 100644
--- a/actionview/lib/action_view/helpers/number_helper.rb
+++ b/actionview/lib/action_view/helpers/number_helper.rb
@@ -1,11 +1,10 @@
-require 'active_support/core_ext/hash/keys'
-require 'active_support/core_ext/string/output_safety'
-require 'active_support/number_helper'
+require "active_support/core_ext/hash/keys"
+require "active_support/core_ext/string/output_safety"
+require "active_support/number_helper"
module ActionView
# = Action View Number Helpers
module Helpers #:nodoc:
-
# Provides methods for converting numbers into formatted strings.
# Methods are provided for phone numbers, currency, percentage,
# precision, positional notation, file size and pretty printing.
@@ -13,7 +12,6 @@ module ActionView
# Most methods expect a +number+ argument, and will return it
# unchanged if can't be converted into a valid number.
module NumberHelper
-
# Raised when argument +number+ param given to the helpers is invalid and
# the option :raise is set to +true+.
class InvalidNumberError < StandardError
@@ -393,53 +391,53 @@ module ActionView
private
- def delegate_number_helper_method(method, number, options)
- return unless number
- options = escape_unsafe_options(options.symbolize_keys)
+ def delegate_number_helper_method(method, number, options)
+ return unless number
+ options = escape_unsafe_options(options.symbolize_keys)
- wrap_with_output_safety_handling(number, options.delete(:raise)) {
- ActiveSupport::NumberHelper.public_send(method, number, options)
- }
- end
+ wrap_with_output_safety_handling(number, options.delete(:raise)) {
+ ActiveSupport::NumberHelper.public_send(method, number, options)
+ }
+ end
- def escape_unsafe_options(options)
- options[:format] = ERB::Util.html_escape(options[:format]) if options[:format]
- options[:negative_format] = ERB::Util.html_escape(options[:negative_format]) if options[:negative_format]
- options[:separator] = ERB::Util.html_escape(options[:separator]) if options[:separator]
- options[:delimiter] = ERB::Util.html_escape(options[:delimiter]) if options[:delimiter]
- options[:unit] = ERB::Util.html_escape(options[:unit]) if options[:unit] && !options[:unit].html_safe?
- options[:units] = escape_units(options[:units]) if options[:units] && Hash === options[:units]
- options
- end
+ def escape_unsafe_options(options)
+ options[:format] = ERB::Util.html_escape(options[:format]) if options[:format]
+ options[:negative_format] = ERB::Util.html_escape(options[:negative_format]) if options[:negative_format]
+ options[:separator] = ERB::Util.html_escape(options[:separator]) if options[:separator]
+ options[:delimiter] = ERB::Util.html_escape(options[:delimiter]) if options[:delimiter]
+ options[:unit] = ERB::Util.html_escape(options[:unit]) if options[:unit] && !options[:unit].html_safe?
+ options[:units] = escape_units(options[:units]) if options[:units] && Hash === options[:units]
+ options
+ end
- def escape_units(units)
- Hash[units.map do |k, v|
- [k, ERB::Util.html_escape(v)]
- end]
- end
+ def escape_units(units)
+ Hash[units.map do |k, v|
+ [k, ERB::Util.html_escape(v)]
+ end]
+ end
- def wrap_with_output_safety_handling(number, raise_on_invalid, &block)
- valid_float = valid_float?(number)
- raise InvalidNumberError, number if raise_on_invalid && !valid_float
+ def wrap_with_output_safety_handling(number, raise_on_invalid, &block)
+ valid_float = valid_float?(number)
+ raise InvalidNumberError, number if raise_on_invalid && !valid_float
- formatted_number = yield
+ formatted_number = yield
- if valid_float || number.html_safe?
- formatted_number.html_safe
- else
- formatted_number
+ if valid_float || number.html_safe?
+ formatted_number.html_safe
+ else
+ formatted_number
+ end
end
- end
- def valid_float?(number)
- !parse_float(number, false).nil?
- end
+ def valid_float?(number)
+ !parse_float(number, false).nil?
+ end
- def parse_float(number, raise_error)
- Float(number)
- rescue ArgumentError, TypeError
- raise InvalidNumberError, number if raise_error
- end
+ def parse_float(number, raise_error)
+ Float(number)
+ rescue ArgumentError, TypeError
+ raise InvalidNumberError, number if raise_error
+ end
end
end
end
diff --git a/actionview/lib/action_view/helpers/output_safety_helper.rb b/actionview/lib/action_view/helpers/output_safety_helper.rb
index d4b55423a8..8e63e59fac 100644
--- a/actionview/lib/action_view/helpers/output_safety_helper.rb
+++ b/actionview/lib/action_view/helpers/output_safety_helper.rb
@@ -1,4 +1,4 @@
-require 'active_support/core_ext/string/output_safety'
+require "active_support/core_ext/string/output_safety"
module ActionView #:nodoc:
# = Action View Raw Output Helper
@@ -42,9 +42,9 @@ module ActionView #:nodoc:
options.assert_valid_keys(:words_connector, :two_words_connector, :last_word_connector, :locale)
default_connectors = {
- :words_connector => ', ',
- :two_words_connector => ' and ',
- :last_word_connector => ', and '
+ words_connector: ", ",
+ two_words_connector: " and ",
+ last_word_connector: ", and "
}
if defined?(I18n)
i18n_connectors = I18n.translate(:'support.array', locale: options[:locale], default: {})
@@ -54,7 +54,7 @@ module ActionView #:nodoc:
case array.length
when 0
- ''.html_safe
+ "".html_safe
when 1
ERB::Util.html_escape(array[0])
when 2
diff --git a/actionview/lib/action_view/helpers/rendering_helper.rb b/actionview/lib/action_view/helpers/rendering_helper.rb
index c98f2d74a8..7d7f2393ff 100644
--- a/actionview/lib/action_view/helpers/rendering_helper.rb
+++ b/actionview/lib/action_view/helpers/rendering_helper.rb
@@ -27,12 +27,12 @@ module ActionView
case options
when Hash
if block_given?
- view_renderer.render_partial(self, options.merge(:partial => options[:layout]), &block)
+ view_renderer.render_partial(self, options.merge(partial: options[:layout]), &block)
else
view_renderer.render(self, options)
end
else
- view_renderer.render_partial(self, :partial => options, :locals => locals, &block)
+ view_renderer.render_partial(self, partial: options, locals: locals, &block)
end
end
diff --git a/actionview/lib/action_view/helpers/sanitize_helper.rb b/actionview/lib/action_view/helpers/sanitize_helper.rb
index f9784c3483..3d6ff598ee 100644
--- a/actionview/lib/action_view/helpers/sanitize_helper.rb
+++ b/actionview/lib/action_view/helpers/sanitize_helper.rb
@@ -1,5 +1,5 @@
-require 'active_support/core_ext/object/try'
-require 'rails-html-sanitizer'
+require "active_support/core_ext/object/try"
+require "rails-html-sanitizer"
module ActionView
# = Action View Sanitize Helpers
diff --git a/actionview/lib/action_view/helpers/tag_helper.rb b/actionview/lib/action_view/helpers/tag_helper.rb
index 4ba37fd5e5..030d07845b 100644
--- a/actionview/lib/action_view/helpers/tag_helper.rb
+++ b/actionview/lib/action_view/helpers/tag_helper.rb
@@ -1,7 +1,7 @@
# frozen-string-literal: true
-require 'active_support/core_ext/string/output_safety'
-require 'set'
+require "active_support/core_ext/string/output_safety"
+require "set"
module ActionView
# = Action View Tag Helpers
@@ -25,7 +25,7 @@ module ActionView
BOOLEAN_ATTRIBUTES.merge(BOOLEAN_ATTRIBUTES.map(&:to_sym))
- TAG_PREFIXES = ['aria', 'data', :aria, :data].to_set
+ TAG_PREFIXES = ["aria", "data", :aria, :data].to_set
PRE_CONTENT_STRINGS = Hash.new { "" }
PRE_CONTENT_STRINGS[:textarea] = "\n"
@@ -46,7 +46,7 @@ module ActionView
if VOID_ELEMENTS.include?(name) && content.nil?
"<#{name.to_s.dasherize}#{tag_options(options, escape_attributes)}>".html_safe
else
- content_tag_string(name.to_s.dasherize, content || '', options, escape_attributes)
+ content_tag_string(name.to_s.dasherize, content || "", options, escape_attributes)
end
end
@@ -109,7 +109,6 @@ module ActionView
def method_missing(called, *args, &block)
tag_string(called, *args, &block)
end
-
end
# Returns an HTML tag.
@@ -290,7 +289,7 @@ module ActionView
# cdata_section("hello]]>world")
# # => <![CDATA[hello]]]]><![CDATA[>world]]>
def cdata_section(content)
- splitted = content.to_s.gsub(/\]\]\>/, ']]]]><![CDATA[>')
+ splitted = content.to_s.gsub(/\]\]\>/, "]]]]><![CDATA[>")
"<![CDATA[#{splitted}]]>".html_safe
end
diff --git a/actionview/lib/action_view/helpers/tags/base.rb b/actionview/lib/action_view/helpers/tags/base.rb
index 086eaa4aab..43335023ce 100644
--- a/actionview/lib/action_view/helpers/tags/base.rb
+++ b/actionview/lib/action_view/helpers/tags/base.rb
@@ -24,136 +24,136 @@ module ActionView
private
- def value(object)
- object.public_send @method_name if object
- end
+ def value(object)
+ object.public_send @method_name if object
+ end
- def value_before_type_cast(object)
- unless object.nil?
- method_before_type_cast = @method_name + "_before_type_cast"
+ def value_before_type_cast(object)
+ unless object.nil?
+ method_before_type_cast = @method_name + "_before_type_cast"
- if value_came_from_user?(object) && object.respond_to?(method_before_type_cast)
- object.public_send(method_before_type_cast)
- else
- value(object)
+ if value_came_from_user?(object) && object.respond_to?(method_before_type_cast)
+ object.public_send(method_before_type_cast)
+ else
+ value(object)
+ end
end
end
- end
- def value_came_from_user?(object)
- method_name = "#{@method_name}_came_from_user?"
- !object.respond_to?(method_name) || object.public_send(method_name)
- end
+ def value_came_from_user?(object)
+ method_name = "#{@method_name}_came_from_user?"
+ !object.respond_to?(method_name) || object.public_send(method_name)
+ end
- def retrieve_object(object)
- if object
- object
- elsif @template_object.instance_variable_defined?("@#{@object_name}")
- @template_object.instance_variable_get("@#{@object_name}")
+ def retrieve_object(object)
+ if object
+ object
+ elsif @template_object.instance_variable_defined?("@#{@object_name}")
+ @template_object.instance_variable_get("@#{@object_name}")
+ end
+ rescue NameError
+ # As @object_name may contain the nested syntax (item[subobject]) we need to fallback to nil.
+ nil
end
- rescue NameError
- # As @object_name may contain the nested syntax (item[subobject]) we need to fallback to nil.
- nil
- end
- def retrieve_autoindex(pre_match)
- object = self.object || @template_object.instance_variable_get("@#{pre_match}")
- if object && object.respond_to?(:to_param)
- object.to_param
- else
- raise ArgumentError, "object[] naming but object param and @object var don't exist or don't respond to to_param: #{object.inspect}"
+ def retrieve_autoindex(pre_match)
+ object = self.object || @template_object.instance_variable_get("@#{pre_match}")
+ if object && object.respond_to?(:to_param)
+ object.to_param
+ else
+ raise ArgumentError, "object[] naming but object param and @object var don't exist or don't respond to to_param: #{object.inspect}"
+ end
end
- end
- def add_default_name_and_id_for_value(tag_value, options)
- if tag_value.nil?
- add_default_name_and_id(options)
- else
- specified_id = options["id"]
- add_default_name_and_id(options)
+ def add_default_name_and_id_for_value(tag_value, options)
+ if tag_value.nil?
+ add_default_name_and_id(options)
+ else
+ specified_id = options["id"]
+ add_default_name_and_id(options)
- if specified_id.blank? && options["id"].present?
- options["id"] += "_#{sanitized_value(tag_value)}"
+ if specified_id.blank? && options["id"].present?
+ options["id"] += "_#{sanitized_value(tag_value)}"
+ end
end
end
- end
- def add_default_name_and_id(options)
- index = name_and_id_index(options)
- options["name"] = options.fetch("name"){ tag_name(options["multiple"], index) }
- options["id"] = options.fetch("id"){ tag_id(index) }
- if namespace = options.delete("namespace")
- options['id'] = options['id'] ? "#{namespace}_#{options['id']}" : namespace
+ def add_default_name_and_id(options)
+ index = name_and_id_index(options)
+ options["name"] = options.fetch("name"){ tag_name(options["multiple"], index) }
+ options["id"] = options.fetch("id"){ tag_id(index) }
+ if namespace = options.delete("namespace")
+ options["id"] = options["id"] ? "#{namespace}_#{options['id']}" : namespace
+ end
end
- end
- def tag_name(multiple = false, index = nil)
- # a little duplication to construct less strings
- if index
- "#{@object_name}[#{index}][#{sanitized_method_name}]#{"[]" if multiple}"
- else
- "#{@object_name}[#{sanitized_method_name}]#{"[]" if multiple}"
+ def tag_name(multiple = false, index = nil)
+ # a little duplication to construct less strings
+ if index
+ "#{@object_name}[#{index}][#{sanitized_method_name}]#{"[]" if multiple}"
+ else
+ "#{@object_name}[#{sanitized_method_name}]#{"[]" if multiple}"
+ end
end
- end
- def tag_id(index = nil)
- # a little duplication to construct less strings
- if index
- "#{sanitized_object_name}_#{index}_#{sanitized_method_name}"
- else
- "#{sanitized_object_name}_#{sanitized_method_name}"
+ def tag_id(index = nil)
+ # a little duplication to construct less strings
+ if index
+ "#{sanitized_object_name}_#{index}_#{sanitized_method_name}"
+ else
+ "#{sanitized_object_name}_#{sanitized_method_name}"
+ end
end
- end
- def sanitized_object_name
- @sanitized_object_name ||= @object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
- end
+ def sanitized_object_name
+ @sanitized_object_name ||= @object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
+ end
- def sanitized_method_name
- @sanitized_method_name ||= @method_name.sub(/\?$/,"")
- end
+ def sanitized_method_name
+ @sanitized_method_name ||= @method_name.sub(/\?$/,"")
+ end
- def sanitized_value(value)
- value.to_s.gsub(/\s/, "_").gsub(/[^-\w]/, "").downcase
- end
+ def sanitized_value(value)
+ value.to_s.gsub(/\s/, "_").gsub(/[^-\w]/, "").downcase
+ end
- def select_content_tag(option_tags, options, html_options)
- html_options = html_options.stringify_keys
- add_default_name_and_id(html_options)
+ def select_content_tag(option_tags, options, html_options)
+ html_options = html_options.stringify_keys
+ add_default_name_and_id(html_options)
- if placeholder_required?(html_options)
- raise ArgumentError, "include_blank cannot be false for a required field." if options[:include_blank] == false
- options[:include_blank] ||= true unless options[:prompt]
- end
+ if placeholder_required?(html_options)
+ raise ArgumentError, "include_blank cannot be false for a required field." if options[:include_blank] == false
+ options[:include_blank] ||= true unless options[:prompt]
+ end
- value = options.fetch(:selected) { value(object) }
- select = content_tag("select", add_options(option_tags, options, value), html_options)
+ value = options.fetch(:selected) { value(object) }
+ select = content_tag("select", add_options(option_tags, options, value), html_options)
- if html_options["multiple"] && options.fetch(:include_hidden, true)
- tag("input", :disabled => html_options["disabled"], :name => html_options["name"], :type => "hidden", :value => "") + select
- else
- select
+ if html_options["multiple"] && options.fetch(:include_hidden, true)
+ tag("input", disabled: html_options["disabled"], name: html_options["name"], type: "hidden", value: "") + select
+ else
+ select
+ end
end
- end
- def placeholder_required?(html_options)
- # See https://html.spec.whatwg.org/multipage/forms.html#attr-select-required
- html_options["required"] && !html_options["multiple"] && html_options.fetch("size", 1).to_i == 1
- end
-
- def add_options(option_tags, options, value = nil)
- if options[:include_blank]
- option_tags = tag_builder.content_tag_string('option', options[:include_blank].kind_of?(String) ? options[:include_blank] : nil, :value => '') + "\n" + option_tags
+ def placeholder_required?(html_options)
+ # See https://html.spec.whatwg.org/multipage/forms.html#attr-select-required
+ html_options["required"] && !html_options["multiple"] && html_options.fetch("size", 1).to_i == 1
end
- if value.blank? && options[:prompt]
- option_tags = tag_builder.content_tag_string('option', prompt_text(options[:prompt]), :value => '') + "\n" + option_tags
+
+ def add_options(option_tags, options, value = nil)
+ if options[:include_blank]
+ option_tags = tag_builder.content_tag_string("option", options[:include_blank].kind_of?(String) ? options[:include_blank] : nil, value: "") + "\n" + option_tags
+ end
+ if value.blank? && options[:prompt]
+ option_tags = tag_builder.content_tag_string("option", prompt_text(options[:prompt]), value: "") + "\n" + option_tags
+ end
+ option_tags
end
- option_tags
- end
- def name_and_id_index(options)
- options.key?("index") ? options.delete("index") || "" : @auto_index
- end
+ def name_and_id_index(options)
+ options.key?("index") ? options.delete("index") || "" : @auto_index
+ end
end
end
end
diff --git a/actionview/lib/action_view/helpers/tags/check_box.rb b/actionview/lib/action_view/helpers/tags/check_box.rb
index 6d51f2629a..02f87fc89f 100644
--- a/actionview/lib/action_view/helpers/tags/check_box.rb
+++ b/actionview/lib/action_view/helpers/tags/check_box.rb
@@ -1,4 +1,4 @@
-require 'action_view/helpers/tags/checkable'
+require "action_view/helpers/tags/checkable"
module ActionView
module Helpers
@@ -38,26 +38,26 @@ module ActionView
private
- def checked?(value)
- case value
- when TrueClass, FalseClass
- value == !!@checked_value
- when NilClass
- false
- when String
- value == @checked_value
- else
- if value.respond_to?(:include?)
- value.include?(@checked_value)
+ def checked?(value)
+ case value
+ when TrueClass, FalseClass
+ value == !!@checked_value
+ when NilClass
+ false
+ when String
+ value == @checked_value
else
- value.to_i == @checked_value.to_i
+ if value.respond_to?(:include?)
+ value.include?(@checked_value)
+ else
+ value.to_i == @checked_value.to_i
+ end
end
end
- end
- def hidden_field_for_checkbox(options)
- @unchecked_value ? tag("input", options.slice("name", "disabled", "form").merge!("type" => "hidden", "value" => @unchecked_value)) : "".html_safe
- end
+ def hidden_field_for_checkbox(options)
+ @unchecked_value ? tag("input", options.slice("name", "disabled", "form").merge!("type" => "hidden", "value" => @unchecked_value)) : "".html_safe
+ end
end
end
end
diff --git a/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb b/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb
index 3dda47a458..2a6bf49567 100644
--- a/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb
+++ b/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb
@@ -1,4 +1,4 @@
-require 'action_view/helpers/tags/collection_helpers'
+require "action_view/helpers/tags/collection_helpers"
module ActionView
module Helpers
@@ -20,13 +20,13 @@ module ActionView
private
- def render_component(builder)
- builder.check_box + builder.label
- end
+ def render_component(builder)
+ builder.check_box + builder.label
+ end
- def hidden_field_name #:nodoc:
- "#{super}[]"
- end
+ def hidden_field_name #:nodoc:
+ "#{super}[]"
+ end
end
end
end
diff --git a/actionview/lib/action_view/helpers/tags/collection_helpers.rb b/actionview/lib/action_view/helpers/tags/collection_helpers.rb
index fb51460c8e..70d7c484eb 100644
--- a/actionview/lib/action_view/helpers/tags/collection_helpers.rb
+++ b/actionview/lib/action_view/helpers/tags/collection_helpers.rb
@@ -36,81 +36,81 @@ module ActionView
private
- def instantiate_builder(builder_class, item, value, text, html_options)
- builder_class.new(@template_object, @object_name, @method_name, item,
- sanitize_attribute_name(value), text, value, html_options)
- end
+ def instantiate_builder(builder_class, item, value, text, html_options)
+ builder_class.new(@template_object, @object_name, @method_name, item,
+ sanitize_attribute_name(value), text, value, html_options)
+ end
# Generate default options for collection helpers, such as :checked and
# :disabled.
- def default_html_options_for_collection(item, value) #:nodoc:
- html_options = @html_options.dup
-
- [:checked, :selected, :disabled, :readonly].each do |option|
- current_value = @options[option]
- next if current_value.nil?
-
- accept = if current_value.respond_to?(:call)
- current_value.call(item)
- else
- Array(current_value).map(&:to_s).include?(value.to_s)
+ def default_html_options_for_collection(item, value) #:nodoc:
+ html_options = @html_options.dup
+
+ [:checked, :selected, :disabled, :readonly].each do |option|
+ current_value = @options[option]
+ next if current_value.nil?
+
+ accept = if current_value.respond_to?(:call)
+ current_value.call(item)
+ else
+ Array(current_value).map(&:to_s).include?(value.to_s)
+ end
+
+ if accept
+ html_options[option] = true
+ elsif option == :checked
+ html_options[option] = false
+ end
end
- if accept
- html_options[option] = true
- elsif option == :checked
- html_options[option] = false
- end
+ html_options[:object] = @object
+ html_options
end
- html_options[:object] = @object
- html_options
- end
+ def sanitize_attribute_name(value) #:nodoc:
+ "#{sanitized_method_name}_#{sanitized_value(value)}"
+ end
- def sanitize_attribute_name(value) #:nodoc:
- "#{sanitized_method_name}_#{sanitized_value(value)}"
- end
+ def render_collection #:nodoc:
+ @collection.map do |item|
+ value = value_for_collection(item, @value_method)
+ text = value_for_collection(item, @text_method)
+ default_html_options = default_html_options_for_collection(item, value)
+ additional_html_options = option_html_attributes(item)
- def render_collection #:nodoc:
- @collection.map do |item|
- value = value_for_collection(item, @value_method)
- text = value_for_collection(item, @text_method)
- default_html_options = default_html_options_for_collection(item, value)
- additional_html_options = option_html_attributes(item)
+ yield item, value, text, default_html_options.merge(additional_html_options)
+ end.join.html_safe
+ end
- yield item, value, text, default_html_options.merge(additional_html_options)
- end.join.html_safe
- end
+ def render_collection_for(builder_class, &block) #:nodoc:
+ options = @options.stringify_keys
+ rendered_collection = render_collection do |item, value, text, default_html_options|
+ builder = instantiate_builder(builder_class, item, value, text, default_html_options)
- def render_collection_for(builder_class, &block) #:nodoc:
- options = @options.stringify_keys
- rendered_collection = render_collection do |item, value, text, default_html_options|
- builder = instantiate_builder(builder_class, item, value, text, default_html_options)
+ if block_given?
+ @template_object.capture(builder, &block)
+ else
+ render_component(builder)
+ end
+ end
- if block_given?
- @template_object.capture(builder, &block)
+ # Prepend a hidden field to make sure something will be sent back to the
+ # server if all radio buttons are unchecked.
+ if options.fetch("include_hidden", true)
+ hidden_field + rendered_collection
else
- render_component(builder)
+ rendered_collection
end
end
- # Prepend a hidden field to make sure something will be sent back to the
- # server if all radio buttons are unchecked.
- if options.fetch('include_hidden', true)
- hidden_field + rendered_collection
- else
- rendered_collection
+ def hidden_field #:nodoc:
+ hidden_name = @html_options[:name] || hidden_field_name
+ @template_object.hidden_field_tag(hidden_name, "", id: nil)
end
- end
- def hidden_field #:nodoc:
- hidden_name = @html_options[:name] || hidden_field_name
- @template_object.hidden_field_tag(hidden_name, "", id: nil)
- end
-
- def hidden_field_name #:nodoc:
- "#{tag_name(false, @options[:index])}"
- end
+ def hidden_field_name #:nodoc:
+ "#{tag_name(false, @options[:index])}"
+ end
end
end
end
diff --git a/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb b/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb
index 21aaf122f8..eed7941cd6 100644
--- a/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb
+++ b/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb
@@ -1,4 +1,4 @@
-require 'action_view/helpers/tags/collection_helpers'
+require "action_view/helpers/tags/collection_helpers"
module ActionView
module Helpers
diff --git a/actionview/lib/action_view/helpers/tags/collection_select.rb b/actionview/lib/action_view/helpers/tags/collection_select.rb
index 6cb2b2e0d3..4365c714eb 100644
--- a/actionview/lib/action_view/helpers/tags/collection_select.rb
+++ b/actionview/lib/action_view/helpers/tags/collection_select.rb
@@ -13,8 +13,8 @@ module ActionView
def render
option_tags_options = {
- :selected => @options.fetch(:selected) { value(@object) },
- :disabled => @options[:disabled]
+ selected: @options.fetch(:selected) { value(@object) },
+ disabled: @options[:disabled]
}
select_content_tag(
diff --git a/actionview/lib/action_view/helpers/tags/date_select.rb b/actionview/lib/action_view/helpers/tags/date_select.rb
index 0c4ac40070..006605885a 100644
--- a/actionview/lib/action_view/helpers/tags/date_select.rb
+++ b/actionview/lib/action_view/helpers/tags/date_select.rb
@@ -1,4 +1,4 @@
-require 'active_support/core_ext/time/calculations'
+require "active_support/core_ext/time/calculations"
module ActionView
module Helpers
@@ -22,50 +22,50 @@ module ActionView
private
- def select_type
- self.class.select_type
- end
+ def select_type
+ self.class.select_type
+ end
- def datetime_selector(options, html_options)
- datetime = options.fetch(:selected) { value(object) || default_datetime(options) }
- @auto_index ||= nil
+ def datetime_selector(options, html_options)
+ datetime = options.fetch(:selected) { value(object) || default_datetime(options) }
+ @auto_index ||= nil
- options = options.dup
- options[:field_name] = @method_name
- options[:include_position] = true
- options[:prefix] ||= @object_name
- options[:index] = @auto_index if @auto_index && !options.has_key?(:index)
+ options = options.dup
+ options[:field_name] = @method_name
+ options[:include_position] = true
+ options[:prefix] ||= @object_name
+ options[:index] = @auto_index if @auto_index && !options.has_key?(:index)
- DateTimeSelector.new(datetime, options, html_options)
- end
+ DateTimeSelector.new(datetime, options, html_options)
+ end
- def default_datetime(options)
- return if options[:include_blank] || options[:prompt]
+ def default_datetime(options)
+ return if options[:include_blank] || options[:prompt]
- case options[:default]
- when nil
- Time.current
- when Date, Time
- options[:default]
- else
- default = options[:default].dup
+ case options[:default]
+ when nil
+ Time.current
+ when Date, Time
+ options[:default]
+ else
+ default = options[:default].dup
- # Rename :minute and :second to :min and :sec
- default[:min] ||= default[:minute]
- default[:sec] ||= default[:second]
+ # Rename :minute and :second to :min and :sec
+ default[:min] ||= default[:minute]
+ default[:sec] ||= default[:second]
- time = Time.current
+ time = Time.current
- [:year, :month, :day, :hour, :min, :sec].each do |key|
- default[key] ||= time.send(key)
- end
+ [:year, :month, :day, :hour, :min, :sec].each do |key|
+ default[key] ||= time.send(key)
+ end
- Time.utc(
- default[:year], default[:month], default[:day],
- default[:hour], default[:min], default[:sec]
- )
+ Time.utc(
+ default[:year], default[:month], default[:day],
+ default[:hour], default[:min], default[:sec]
+ )
+ end
end
- end
end
end
end
diff --git a/actionview/lib/action_view/helpers/tags/grouped_collection_select.rb b/actionview/lib/action_view/helpers/tags/grouped_collection_select.rb
index 2ed4712dac..20e312dd0f 100644
--- a/actionview/lib/action_view/helpers/tags/grouped_collection_select.rb
+++ b/actionview/lib/action_view/helpers/tags/grouped_collection_select.rb
@@ -15,8 +15,8 @@ module ActionView
def render
option_tags_options = {
- :selected => @options.fetch(:selected) { value(@object) },
- :disabled => @options[:disabled]
+ selected: @options.fetch(:selected) { value(@object) },
+ disabled: @options[:disabled]
}
select_content_tag(
diff --git a/actionview/lib/action_view/helpers/tags/password_field.rb b/actionview/lib/action_view/helpers/tags/password_field.rb
index 6099fa6f19..274c27df82 100644
--- a/actionview/lib/action_view/helpers/tags/password_field.rb
+++ b/actionview/lib/action_view/helpers/tags/password_field.rb
@@ -3,7 +3,7 @@ module ActionView
module Tags # :nodoc:
class PasswordField < TextField # :nodoc:
def render
- @options = {:value => nil}.merge!(@options)
+ @options = {value: nil}.merge!(@options)
super
end
end
diff --git a/actionview/lib/action_view/helpers/tags/radio_button.rb b/actionview/lib/action_view/helpers/tags/radio_button.rb
index 4849c537a5..43dbd32083 100644
--- a/actionview/lib/action_view/helpers/tags/radio_button.rb
+++ b/actionview/lib/action_view/helpers/tags/radio_button.rb
@@ -1,4 +1,4 @@
-require 'action_view/helpers/tags/checkable'
+require "action_view/helpers/tags/checkable"
module ActionView
module Helpers
@@ -22,9 +22,9 @@ module ActionView
private
- def checked?(value)
- value.to_s == @tag_value.to_s
- end
+ def checked?(value)
+ value.to_s == @tag_value.to_s
+ end
end
end
end
diff --git a/actionview/lib/action_view/helpers/tags/select.rb b/actionview/lib/action_view/helpers/tags/select.rb
index 180900cc8d..8cc34e3180 100644
--- a/actionview/lib/action_view/helpers/tags/select.rb
+++ b/actionview/lib/action_view/helpers/tags/select.rb
@@ -13,8 +13,8 @@ module ActionView
def render
option_tags_options = {
- :selected => @options.fetch(:selected) { value(@object) },
- :disabled => @options[:disabled]
+ selected: @options.fetch(:selected) { value(@object) },
+ disabled: @options[:disabled]
}
option_tags = if grouped_choices?
@@ -32,9 +32,9 @@ module ActionView
#
# [nil, []]
# { nil => [] }
- def grouped_choices?
- !@choices.empty? && @choices.first.respond_to?(:last) && Array === @choices.first.last
- end
+ def grouped_choices?
+ !@choices.empty? && @choices.first.respond_to?(:last) && Array === @choices.first.last
+ end
end
end
end
diff --git a/actionview/lib/action_view/helpers/tags/text_area.rb b/actionview/lib/action_view/helpers/tags/text_area.rb
index 69038c1498..31e3a9e9b1 100644
--- a/actionview/lib/action_view/helpers/tags/text_area.rb
+++ b/actionview/lib/action_view/helpers/tags/text_area.rb
@@ -1,4 +1,4 @@
-require 'action_view/helpers/tags/placeholderable'
+require "action_view/helpers/tags/placeholderable"
module ActionView
module Helpers
diff --git a/actionview/lib/action_view/helpers/tags/text_field.rb b/actionview/lib/action_view/helpers/tags/text_field.rb
index 5c576a20ca..4306c3543d 100644
--- a/actionview/lib/action_view/helpers/tags/text_field.rb
+++ b/actionview/lib/action_view/helpers/tags/text_field.rb
@@ -1,4 +1,4 @@
-require 'action_view/helpers/tags/placeholderable'
+require "action_view/helpers/tags/placeholderable"
module ActionView
module Helpers
@@ -23,9 +23,9 @@ module ActionView
private
- def field_type
- self.class.field_type
- end
+ def field_type
+ self.class.field_type
+ end
end
end
end
diff --git a/actionview/lib/action_view/helpers/tags/translator.rb b/actionview/lib/action_view/helpers/tags/translator.rb
index 8b6655481d..62b1df81c6 100644
--- a/actionview/lib/action_view/helpers/tags/translator.rb
+++ b/actionview/lib/action_view/helpers/tags/translator.rb
@@ -16,24 +16,24 @@ module ActionView
protected
- attr_reader :object_name, :method_and_value, :scope, :model
+ attr_reader :object_name, :method_and_value, :scope, :model
private
- def i18n_default
- if model
- key = model.model_name.i18n_key
- ["#{key}.#{method_and_value}".to_sym, ""]
- else
- ""
+ def i18n_default
+ if model
+ key = model.model_name.i18n_key
+ ["#{key}.#{method_and_value}".to_sym, ""]
+ else
+ ""
+ end
end
- end
- def human_attribute_name
- if model && model.class.respond_to?(:human_attribute_name)
- model.class.human_attribute_name(method_and_value)
+ def human_attribute_name
+ if model && model.class.respond_to?(:human_attribute_name)
+ model.class.human_attribute_name(method_and_value)
+ end
end
- end
end
end
end
diff --git a/actionview/lib/action_view/helpers/text_helper.rb b/actionview/lib/action_view/helpers/text_helper.rb
index fe365fafe1..0fea4df09c 100644
--- a/actionview/lib/action_view/helpers/text_helper.rb
+++ b/actionview/lib/action_view/helpers/text_helper.rb
@@ -1,5 +1,5 @@
-require 'active_support/core_ext/string/filters'
-require 'active_support/core_ext/array/extract_options'
+require "active_support/core_ext/string/filters"
+require "active_support/core_ext/array/extract_options"
module ActionView
# = Action View Text Helpers
@@ -135,7 +135,7 @@ module ActionView
else
match = Array(phrases).map do |p|
Regexp === p ? p.to_s : Regexp.escape(p)
- end.join('|')
+ end.join("|")
if block_given?
text.gsub(/(#{match})(?![^<]*?>)/i) { |found| yield found }
@@ -358,7 +358,7 @@ module ActionView
# <% end %>
def cycle(first_value, *values)
options = values.extract_options!
- name = options.fetch(:name, 'default')
+ name = options.fetch(:name, "default")
values.unshift(*first_value)
@@ -432,17 +432,17 @@ module ActionView
private
- def next_index
- step_index(1)
- end
+ def next_index
+ step_index(1)
+ end
- def previous_index
- step_index(-1)
- end
+ def previous_index
+ step_index(-1)
+ end
- def step_index(n)
- (@index + n) % @values.size
- end
+ def step_index(n)
+ (@index + n) % @values.size
+ end
end
private
diff --git a/actionview/lib/action_view/helpers/translation_helper.rb b/actionview/lib/action_view/helpers/translation_helper.rb
index 622bb193ae..cbabaf5757 100644
--- a/actionview/lib/action_view/helpers/translation_helper.rb
+++ b/actionview/lib/action_view/helpers/translation_helper.rb
@@ -1,7 +1,7 @@
-require 'action_view/helpers/tag_helper'
-require 'active_support/core_ext/string/access'
-require 'active_support/core_ext/regexp'
-require 'i18n/exceptions'
+require "action_view/helpers/tag_helper"
+require "active_support/core_ext/string/access"
+require "active_support/core_ext/regexp"
+require "i18n/exceptions"
module ActionView
# = Action View Translation Helpers
@@ -101,12 +101,12 @@ module ActionView
interpolations = options.except(:default, :scope)
if interpolations.any?
- title << ", " << interpolations.map { |k, v| "#{k}: #{ERB::Util.html_escape(v)}" }.join(', ')
+ title << ", " << interpolations.map { |k, v| "#{k}: #{ERB::Util.html_escape(v)}" }.join(", ")
end
return title unless ActionView::Base.debug_missing_translation
- content_tag('span', keys.last.to_s.titleize, class: 'translation_missing', title: title)
+ content_tag("span", keys.last.to_s.titleize, class: "translation_missing", title: title)
end
end
alias :t :translate
diff --git a/actionview/lib/action_view/helpers/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb
index 5d7940a7b1..82aeeedad9 100644
--- a/actionview/lib/action_view/helpers/url_helper.rb
+++ b/actionview/lib/action_view/helpers/url_helper.rb
@@ -1,8 +1,8 @@
-require 'action_view/helpers/javascript_helper'
-require 'active_support/core_ext/array/access'
-require 'active_support/core_ext/hash/keys'
-require 'active_support/core_ext/string/output_safety'
-require 'active_support/core_ext/regexp'
+require "action_view/helpers/javascript_helper"
+require "active_support/core_ext/array/access"
+require "active_support/core_ext/hash/keys"
+require "active_support/core_ext/string/output_safety"
+require "active_support/core_ext/regexp"
module ActionView
# = Action View URL Helpers
@@ -42,14 +42,14 @@ module ActionView
end
def _back_url # :nodoc:
- _filtered_referrer || 'javascript:history.back()'
+ _filtered_referrer || "javascript:history.back()"
end
protected :_back_url
def _filtered_referrer # :nodoc:
if controller.respond_to?(:request)
referrer = controller.request.env["HTTP_REFERER"]
- if referrer && URI(referrer).scheme != 'javascript'
+ if referrer && URI(referrer).scheme != "javascript"
referrer
end
end
@@ -299,34 +299,34 @@ module ActionView
html_options = html_options.stringify_keys
url = options.is_a?(String) ? options : url_for(options)
- remote = html_options.delete('remote')
- params = html_options.delete('params')
+ remote = html_options.delete("remote")
+ params = html_options.delete("params")
- method = html_options.delete('method').to_s
- method_tag = BUTTON_TAG_METHOD_VERBS.include?(method) ? method_tag(method) : ''.freeze.html_safe
+ method = html_options.delete("method").to_s
+ method_tag = BUTTON_TAG_METHOD_VERBS.include?(method) ? method_tag(method) : "".freeze.html_safe
- form_method = method == 'get' ? 'get' : 'post'
- form_options = html_options.delete('form') || {}
- form_options[:class] ||= html_options.delete('form_class') || 'button_to'
+ form_method = method == "get" ? "get" : "post"
+ form_options = html_options.delete("form") || {}
+ form_options[:class] ||= html_options.delete("form_class") || "button_to"
form_options[:method] = form_method
form_options[:action] = url
form_options[:'data-remote'] = true if remote
- request_token_tag = if form_method == 'post'
- request_method = method.empty? ? 'post' : method
+ request_token_tag = if form_method == "post"
+ request_method = method.empty? ? "post" : method
token_tag(nil, form_options: { action: url, method: request_method })
else
- ''.freeze
+ "".freeze
end
html_options = convert_options_to_data_attributes(options, html_options)
- html_options['type'] = 'submit'
+ html_options["type"] = "submit"
button = if block_given?
- content_tag('button', html_options, &block)
+ content_tag("button", html_options, &block)
else
- html_options['value'] = name || url
- tag('input', html_options)
+ html_options["value"] = name || url
+ tag("input", html_options)
end
inner_tags = method_tag.safe_concat(button).safe_concat(request_token_tag)
@@ -335,7 +335,7 @@ module ActionView
inner_tags.safe_concat tag(:input, type: "hidden", name: param[:name], value: param[:value])
end
end
- content_tag('form', inner_tags, form_options)
+ content_tag("form", inner_tags, form_options)
end
# Creates a link tag of the given +name+ using a URL created by the set of
@@ -482,7 +482,7 @@ module ActionView
option = html_options.delete(item).presence || next
"#{item.dasherize}=#{ERB::Util.url_encode(option)}"
}.compact
- extras = extras.empty? ? ''.freeze : '?' + extras.join('&')
+ extras = extras.empty? ? "".freeze : "?" + extras.join("&")
encoded_email_address = ERB::Util.url_encode(email_address).gsub("%40", "@")
html_options["href"] = "mailto:#{encoded_email_address}#{extras}"
@@ -562,21 +562,21 @@ module ActionView
def convert_options_to_data_attributes(options, html_options)
if html_options
html_options = html_options.stringify_keys
- html_options['data-remote'] = 'true'.freeze if link_to_remote_options?(options) || link_to_remote_options?(html_options)
+ html_options["data-remote"] = "true".freeze if link_to_remote_options?(options) || link_to_remote_options?(html_options)
- method = html_options.delete('method'.freeze)
+ method = html_options.delete("method".freeze)
add_method_to_attributes!(html_options, method) if method
html_options
else
- link_to_remote_options?(options) ? {'data-remote' => 'true'.freeze} : {}
+ link_to_remote_options?(options) ? {"data-remote" => "true".freeze} : {}
end
end
def link_to_remote_options?(options)
if options.is_a?(Hash)
- options.delete('remote'.freeze) || options.delete(:remote)
+ options.delete("remote".freeze) || options.delete(:remote)
end
end
@@ -592,12 +592,12 @@ module ActionView
token ||= form_authenticity_token(form_options: form_options)
tag(:input, type: "hidden", name: request_forgery_protection_token.to_s, value: token)
else
- ''.freeze
+ "".freeze
end
end
def method_tag(method)
- tag('input', type: 'hidden', name: '_method', value: method.to_s)
+ tag("input", type: "hidden", name: "_method", value: method.to_s)
end
# Returns an array of hashes each containing :name and :value keys
diff --git a/actionview/lib/action_view/layouts.rb b/actionview/lib/action_view/layouts.rb
index 8e956c47c6..b2fcd823d2 100644
--- a/actionview/lib/action_view/layouts.rb
+++ b/actionview/lib/action_view/layouts.rb
@@ -1,6 +1,6 @@
-require 'action_view/rendering'
-require 'active_support/core_ext/module/remove_method'
-require 'active_support/core_ext/regexp'
+require "action_view/rendering"
+require "active_support/core_ext/module/remove_method"
+require "active_support/core_ext/regexp"
module ActionView
# Layouts reverse the common pattern of including shared headers and footers in many templates to isolate changes in
@@ -205,7 +205,7 @@ module ActionView
include ActionView::Rendering
included do
- class_attribute :_layout, :_layout_conditions, :instance_accessor => false
+ class_attribute :_layout, :_layout_conditions, instance_accessor: false
self._layout = nil
self._layout_conditions = {}
_write_layout_method
@@ -230,19 +230,19 @@ module ActionView
#
# ==== Returns
# * <tt>Boolean</tt> - True if the action has a layout definition, false otherwise.
- def _conditional_layout?
- return unless super
+ def _conditional_layout?
+ return unless super
- conditions = _layout_conditions
+ conditions = _layout_conditions
- if only = conditions[:only]
- only.include?(action_name)
- elsif except = conditions[:except]
- !except.include?(action_name)
- else
- true
+ if only = conditions[:only]
+ only.include?(action_name)
+ elsif except = conditions[:except]
+ !except.include?(action_name)
+ else
+ true
+ end
end
- end
end
# Specify the layout to use for this class.
@@ -291,10 +291,10 @@ module ActionView
end
layout_definition = case _layout
- when String
- _layout.inspect
- when Symbol
- <<-RUBY
+ when String
+ _layout.inspect
+ when Symbol
+ <<-RUBY
#{_layout}.tap do |layout|
return #{default_behavior} if layout.nil?
unless layout.is_a?(String) || !layout
@@ -303,20 +303,20 @@ module ActionView
end
end
RUBY
- when Proc
- define_method :_layout_from_proc, &_layout
- protected :_layout_from_proc
- <<-RUBY
+ when Proc
+ define_method :_layout_from_proc, &_layout
+ protected :_layout_from_proc
+ <<-RUBY
result = _layout_from_proc(#{_layout.arity == 0 ? '' : 'self'})
return #{default_behavior} if result.nil?
result
RUBY
- when false
- nil
- when true
- raise ArgumentError, "Layouts must be specified as a String, Symbol, Proc, false, or nil"
- when nil
- name_clause
+ when false
+ nil
+ when true
+ raise ArgumentError, "Layouts must be specified as a String, Symbol, Proc, false, or nil"
+ when nil
+ name_clause
end
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
@@ -338,9 +338,9 @@ module ActionView
#
# ==== Returns
# * <tt>String</tt> - A template name
- def _implied_layout_name # :nodoc:
- controller_path
- end
+ def _implied_layout_name # :nodoc:
+ controller_path
+ end
end
def _normalize_options(options) # :nodoc:
diff --git a/actionview/lib/action_view/log_subscriber.rb b/actionview/lib/action_view/log_subscriber.rb
index 5a29c68214..34e1a35dc2 100644
--- a/actionview/lib/action_view/log_subscriber.rb
+++ b/actionview/lib/action_view/log_subscriber.rb
@@ -1,4 +1,4 @@
-require 'active_support/log_subscriber'
+require "active_support/log_subscriber"
module ActionView
# = Action View Log Subscriber
@@ -22,7 +22,7 @@ module ActionView
alias :render_partial :render_template
def render_collection(event)
- identifier = event.payload[:identifier] || 'templates'
+ identifier = event.payload[:identifier] || "templates"
info do
" Rendered collection of #{from_rails_root(identifier)}" \
@@ -44,7 +44,7 @@ module ActionView
protected
- EMPTY = ''
+ EMPTY = ""
def from_rails_root(string)
string = string.sub(rails_root, EMPTY)
string.sub!(VIEWS_PATTERN, EMPTY)
diff --git a/actionview/lib/action_view/lookup_context.rb b/actionview/lib/action_view/lookup_context.rb
index 9db1460ee7..969bc48bdc 100644
--- a/actionview/lib/action_view/lookup_context.rb
+++ b/actionview/lib/action_view/lookup_context.rb
@@ -1,7 +1,7 @@
-require 'concurrent/map'
-require 'active_support/core_ext/module/remove_method'
-require 'active_support/core_ext/module/attribute_accessors'
-require 'action_view/template/resolver'
+require "concurrent/map"
+require "active_support/core_ext/module/remove_method"
+require "active_support/core_ext/module/attribute_accessors"
+require "action_view/template/resolver"
module ActionView
# = Action View Lookup Context
@@ -202,13 +202,13 @@ module ActionView
# name instead of the prefix.
def normalize_name(name, prefixes) #:nodoc:
prefixes = prefixes.presence
- parts = name.to_s.split('/'.freeze)
+ parts = name.to_s.split("/".freeze)
parts.shift if parts.first.empty?
name = parts.pop
return name, prefixes || [""] if parts.empty?
- parts = parts.join('/'.freeze)
+ parts = parts.join("/".freeze)
prefixes = prefixes ? prefixes.map { |p| "#{p}/#{parts}" } : [parts]
return name, prefixes
diff --git a/actionview/lib/action_view/path_set.rb b/actionview/lib/action_view/path_set.rb
index f68d2a77ed..6688519ffd 100644
--- a/actionview/lib/action_view/path_set.rb
+++ b/actionview/lib/action_view/path_set.rb
@@ -69,30 +69,30 @@ module ActionView #:nodoc:
private
- def _find_all(path, prefixes, args, outside_app)
- prefixes = [prefixes] if String === prefixes
- prefixes.each do |prefix|
- paths.each do |resolver|
- if outside_app
- templates = resolver.find_all_anywhere(path, prefix, *args)
- else
- templates = resolver.find_all(path, prefix, *args)
+ def _find_all(path, prefixes, args, outside_app)
+ prefixes = [prefixes] if String === prefixes
+ prefixes.each do |prefix|
+ paths.each do |resolver|
+ if outside_app
+ templates = resolver.find_all_anywhere(path, prefix, *args)
+ else
+ templates = resolver.find_all(path, prefix, *args)
+ end
+ return templates unless templates.empty?
end
- return templates unless templates.empty?
end
+ []
end
- []
- end
- def typecast(paths)
- paths.map do |path|
- case path
- when Pathname, String
- OptimizedFileSystemResolver.new path.to_s
- else
- path
+ def typecast(paths)
+ paths.map do |path|
+ case path
+ when Pathname, String
+ OptimizedFileSystemResolver.new path.to_s
+ else
+ path
+ end
end
end
- end
end
end
diff --git a/actionview/lib/action_view/record_identifier.rb b/actionview/lib/action_view/record_identifier.rb
index 4a2547b0fb..b39acfa0b5 100644
--- a/actionview/lib/action_view/record_identifier.rb
+++ b/actionview/lib/action_view/record_identifier.rb
@@ -1,5 +1,5 @@
-require 'active_support/core_ext/module'
-require 'action_view/model_naming'
+require "active_support/core_ext/module"
+require "action_view/model_naming"
module ActionView
# RecordIdentifier encapsulates methods used by various ActionView helpers
@@ -57,8 +57,8 @@ module ActionView
include ModelNaming
- JOIN = '_'.freeze
- NEW = 'new'.freeze
+ JOIN = "_".freeze
+ NEW = "new".freeze
# The DOM class convention is to use the singular form of an object or class.
#
diff --git a/actionview/lib/action_view/renderer/abstract_renderer.rb b/actionview/lib/action_view/renderer/abstract_renderer.rb
index 1dddf53df0..3c85be49cd 100644
--- a/actionview/lib/action_view/renderer/abstract_renderer.rb
+++ b/actionview/lib/action_view/renderer/abstract_renderer.rb
@@ -15,7 +15,7 @@ module ActionView
# that new object is called in turn. This abstracts the setup and rendering
# into a separate classes for partials and templates.
class AbstractRenderer #:nodoc:
- delegate :find_template, :find_file, :template_exists?, :any_templates?, :with_fallbacks, :with_layout_format, :formats, :to => :@lookup_context
+ delegate :find_template, :find_file, :template_exists?, :any_templates?, :with_fallbacks, :with_layout_format, :formats, to: :@lookup_context
def initialize(lookup_context)
@lookup_context = lookup_context
@@ -27,27 +27,27 @@ module ActionView
protected
- def extract_details(options)
- @lookup_context.registered_details.each_with_object({}) do |key, details|
- value = options[key]
+ def extract_details(options)
+ @lookup_context.registered_details.each_with_object({}) do |key, details|
+ value = options[key]
- details[key] = Array(value) if value
+ details[key] = Array(value) if value
+ end
end
- end
- def instrument(name, **options)
- options[:identifier] ||= (@template && @template.identifier) || @path
+ def instrument(name, **options)
+ options[:identifier] ||= (@template && @template.identifier) || @path
- ActiveSupport::Notifications.instrument("render_#{name}.action_view", options) do |payload|
- yield payload
+ ActiveSupport::Notifications.instrument("render_#{name}.action_view", options) do |payload|
+ yield payload
+ end
end
- end
- def prepend_formats(formats)
- formats = Array(formats)
- return if formats.empty? || @lookup_context.html_fallback_for_js
+ def prepend_formats(formats)
+ formats = Array(formats)
+ return if formats.empty? || @lookup_context.html_fallback_for_js
- @lookup_context.formats = formats | @lookup_context.formats
- end
+ @lookup_context.formats = formats | @lookup_context.formats
+ end
end
end
diff --git a/actionview/lib/action_view/renderer/partial_renderer.rb b/actionview/lib/action_view/renderer/partial_renderer.rb
index 7c2e07185c..1509726a37 100644
--- a/actionview/lib/action_view/renderer/partial_renderer.rb
+++ b/actionview/lib/action_view/renderer/partial_renderer.rb
@@ -1,6 +1,6 @@
-require 'concurrent/map'
-require 'active_support/core_ext/regexp'
-require 'action_view/renderer/partial_renderer/collection_caching'
+require "concurrent/map"
+require "active_support/core_ext/regexp"
+require "action_view/renderer/partial_renderer/collection_caching"
module ActionView
class PartialIteration
@@ -316,38 +316,38 @@ module ActionView
private
- def render_collection
- instrument(:collection, count: @collection.size) do |payload|
- return nil if @collection.blank?
+ def render_collection
+ instrument(:collection, count: @collection.size) do |payload|
+ return nil if @collection.blank?
- if @options.key?(:spacer_template)
- spacer = find_template(@options[:spacer_template], @locals.keys).render(@view, @locals)
- end
+ if @options.key?(:spacer_template)
+ spacer = find_template(@options[:spacer_template], @locals.keys).render(@view, @locals)
+ end
- cache_collection_render(payload) do
- @template ? collection_with_template : collection_without_template
- end.join(spacer).html_safe
+ cache_collection_render(payload) do
+ @template ? collection_with_template : collection_without_template
+ end.join(spacer).html_safe
+ end
end
- end
- def render_partial
- view, locals, block = @view, @locals, @block
- object, as = @object, @variable
+ def render_partial
+ view, locals, block = @view, @locals, @block
+ object, as = @object, @variable
- if !block && (layout = @options[:layout])
- layout = find_template(layout.to_s, @template_keys)
- end
+ if !block && (layout = @options[:layout])
+ layout = find_template(layout.to_s, @template_keys)
+ end
- object = locals[as] if object.nil? # Respect object when object is false
- locals[as] = object if @has_object
+ object = locals[as] if object.nil? # Respect object when object is false
+ locals[as] = object if @has_object
- content = @template.render(view, locals) do |*name|
- view._layout_for(*name, &block)
- end
+ content = @template.render(view, locals) do |*name|
+ view._layout_for(*name, &block)
+ end
- content = layout.render(view, locals){ content } if layout
- content
- end
+ content = layout.render(view, locals){ content } if layout
+ content
+ end
# Sets up instance variables needed for rendering a partial. This method
# finds the options and details and extracts them. The method also contains
@@ -356,114 +356,114 @@ module ActionView
# If +options[:partial]+ is a string, then the +@path+ instance variable is
# set to that string. Otherwise, the +options[:partial]+ object must
# respond to +to_partial_path+ in order to setup the path.
- def setup(context, options, block)
- @view = context
- @options = options
- @block = block
+ def setup(context, options, block)
+ @view = context
+ @options = options
+ @block = block
- @locals = options[:locals] || {}
- @details = extract_details(options)
+ @locals = options[:locals] || {}
+ @details = extract_details(options)
- prepend_formats(options[:formats])
+ prepend_formats(options[:formats])
- partial = options[:partial]
+ partial = options[:partial]
- if String === partial
- @has_object = options.key?(:object)
- @object = options[:object]
- @collection = collection_from_options
- @path = partial
- else
- @has_object = true
- @object = partial
- @collection = collection_from_object || collection_from_options
+ if String === partial
+ @has_object = options.key?(:object)
+ @object = options[:object]
+ @collection = collection_from_options
+ @path = partial
+ else
+ @has_object = true
+ @object = partial
+ @collection = collection_from_object || collection_from_options
+
+ if @collection
+ paths = @collection_data = @collection.map { |o| partial_path(o) }
+ @path = paths.uniq.one? ? paths.first : nil
+ else
+ @path = partial_path
+ end
+ end
- if @collection
- paths = @collection_data = @collection.map { |o| partial_path(o) }
- @path = paths.uniq.one? ? paths.first : nil
+ if as = options[:as]
+ raise_invalid_option_as(as) unless /\A[a-z_]\w*\z/.match?(as.to_s)
+ as = as.to_sym
+ end
+
+ if @path
+ @variable, @variable_counter, @variable_iteration = retrieve_variable(@path, as)
+ @template_keys = retrieve_template_keys
else
- @path = partial_path
+ paths.map! { |path| retrieve_variable(path, as).unshift(path) }
end
+
+ self
end
- if as = options[:as]
- raise_invalid_option_as(as) unless /\A[a-z_]\w*\z/.match?(as.to_s)
- as = as.to_sym
+ def collection_from_options
+ if @options.key?(:collection)
+ collection = @options[:collection]
+ collection ? collection.to_a : []
+ end
end
- if @path
- @variable, @variable_counter, @variable_iteration = retrieve_variable(@path, as)
- @template_keys = retrieve_template_keys
- else
- paths.map! { |path| retrieve_variable(path, as).unshift(path) }
+ def collection_from_object
+ @object.to_ary if @object.respond_to?(:to_ary)
end
- self
- end
+ def find_partial
+ find_template(@path, @template_keys) if @path
+ end
- def collection_from_options
- if @options.key?(:collection)
- collection = @options[:collection]
- collection ? collection.to_a : []
+ def find_template(path, locals)
+ prefixes = path.include?(?/) ? [] : @lookup_context.prefixes
+ @lookup_context.find_template(path, prefixes, true, locals, @details)
end
- end
- def collection_from_object
- @object.to_ary if @object.respond_to?(:to_ary)
- end
+ def collection_with_template
+ view, locals, template = @view, @locals, @template
+ as, counter, iteration = @variable, @variable_counter, @variable_iteration
- def find_partial
- find_template(@path, @template_keys) if @path
- end
+ if layout = @options[:layout]
+ layout = find_template(layout, @template_keys)
+ end
- def find_template(path, locals)
- prefixes = path.include?(?/) ? [] : @lookup_context.prefixes
- @lookup_context.find_template(path, prefixes, true, locals, @details)
- end
+ partial_iteration = PartialIteration.new(@collection.size)
+ locals[iteration] = partial_iteration
- def collection_with_template
- view, locals, template = @view, @locals, @template
- as, counter, iteration = @variable, @variable_counter, @variable_iteration
+ @collection.map do |object|
+ locals[as] = object
+ locals[counter] = partial_iteration.index
- if layout = @options[:layout]
- layout = find_template(layout, @template_keys)
+ content = template.render(view, locals)
+ content = layout.render(view, locals) { content } if layout
+ partial_iteration.iterate!
+ content
+ end
end
- partial_iteration = PartialIteration.new(@collection.size)
- locals[iteration] = partial_iteration
-
- @collection.map do |object|
- locals[as] = object
- locals[counter] = partial_iteration.index
-
- content = template.render(view, locals)
- content = layout.render(view, locals) { content } if layout
- partial_iteration.iterate!
- content
- end
- end
+ def collection_without_template
+ view, locals, collection_data = @view, @locals, @collection_data
+ cache = {}
+ keys = @locals.keys
- def collection_without_template
- view, locals, collection_data = @view, @locals, @collection_data
- cache = {}
- keys = @locals.keys
+ partial_iteration = PartialIteration.new(@collection.size)
- partial_iteration = PartialIteration.new(@collection.size)
+ @collection.map do |object|
+ index = partial_iteration.index
+ path, as, counter, iteration = collection_data[index]
- @collection.map do |object|
- index = partial_iteration.index
- path, as, counter, iteration = collection_data[index]
+ locals[as] = object
+ locals[counter] = index
+ locals[iteration] = partial_iteration
- locals[as] = object
- locals[counter] = index
- locals[iteration] = partial_iteration
-
- template = (cache[path] ||= find_template(path, keys + [as, counter]))
- content = template.render(view, locals)
- partial_iteration.iterate!
- content
+ template = (cache[path] ||= find_template(path, keys + [as, counter]))
+ content = template.render(view, locals)
+ partial_iteration.iterate!
+ content
+ end
end
- end
# Obtains the path to where the object's partial is located. If the object
# responds to +to_partial_path+, then +to_partial_path+ will be called and
@@ -472,79 +472,79 @@ module ActionView
#
# If +prefix_partial_path_with_controller_namespace+ is true, then this
# method will prefix the partial paths with a namespace.
- def partial_path(object = @object)
- object = object.to_model if object.respond_to?(:to_model)
+ def partial_path(object = @object)
+ object = object.to_model if object.respond_to?(:to_model)
- path = if object.respond_to?(:to_partial_path)
- object.to_partial_path
- else
- raise ArgumentError.new("'#{object.inspect}' is not an ActiveModel-compatible object. It must implement :to_partial_path.")
+ path = if object.respond_to?(:to_partial_path)
+ object.to_partial_path
+ else
+ raise ArgumentError.new("'#{object.inspect}' is not an ActiveModel-compatible object. It must implement :to_partial_path.")
+ end
+
+ if @view.prefix_partial_path_with_controller_namespace
+ prefixed_partial_names[path] ||= merge_prefix_into_object_path(@context_prefix, path.dup)
+ else
+ path
+ end
end
- if @view.prefix_partial_path_with_controller_namespace
- prefixed_partial_names[path] ||= merge_prefix_into_object_path(@context_prefix, path.dup)
- else
- path
+ def prefixed_partial_names
+ @prefixed_partial_names ||= PREFIXED_PARTIAL_NAMES[@context_prefix]
end
- end
- def prefixed_partial_names
- @prefixed_partial_names ||= PREFIXED_PARTIAL_NAMES[@context_prefix]
- end
+ def merge_prefix_into_object_path(prefix, object_path)
+ if prefix.include?(?/) && object_path.include?(?/)
+ prefixes = []
+ prefix_array = File.dirname(prefix).split("/")
+ object_path_array = object_path.split("/")[0..-3] # skip model dir & partial
- def merge_prefix_into_object_path(prefix, object_path)
- if prefix.include?(?/) && object_path.include?(?/)
- prefixes = []
- prefix_array = File.dirname(prefix).split('/')
- object_path_array = object_path.split('/')[0..-3] # skip model dir & partial
+ prefix_array.each_with_index do |dir, index|
+ break if dir == object_path_array[index]
+ prefixes << dir
+ end
- prefix_array.each_with_index do |dir, index|
- break if dir == object_path_array[index]
- prefixes << dir
+ (prefixes << object_path).join("/")
+ else
+ object_path
end
-
- (prefixes << object_path).join("/")
- else
- object_path
end
- end
- def retrieve_template_keys
- keys = @locals.keys
- keys << @variable if @has_object || @collection
- if @collection
- keys << @variable_counter
- keys << @variable_iteration
+ def retrieve_template_keys
+ keys = @locals.keys
+ keys << @variable if @has_object || @collection
+ if @collection
+ keys << @variable_counter
+ keys << @variable_iteration
+ end
+ keys
end
- keys
- end
- def retrieve_variable(path, as)
- variable = as || begin
- base = path[-1] == "/".freeze ? "".freeze : File.basename(path)
- raise_invalid_identifier(path) unless base =~ /\A_?(.*?)(?:\.\w+)*\z/
- $1.to_sym
- end
- if @collection
- variable_counter = :"#{variable}_counter"
- variable_iteration = :"#{variable}_iteration"
+ def retrieve_variable(path, as)
+ variable = as || begin
+ base = path[-1] == "/".freeze ? "".freeze : File.basename(path)
+ raise_invalid_identifier(path) unless base =~ /\A_?(.*?)(?:\.\w+)*\z/
+ $1.to_sym
+ end
+ if @collection
+ variable_counter = :"#{variable}_counter"
+ variable_iteration = :"#{variable}_iteration"
+ end
+ [variable, variable_counter, variable_iteration]
end
- [variable, variable_counter, variable_iteration]
- end
- IDENTIFIER_ERROR_MESSAGE = "The partial name (%s) is not a valid Ruby identifier; " +
- "make sure your partial name starts with underscore."
+ IDENTIFIER_ERROR_MESSAGE = "The partial name (%s) is not a valid Ruby identifier; " +
+ "make sure your partial name starts with underscore."
- OPTION_AS_ERROR_MESSAGE = "The value (%s) of the option `as` is not a valid Ruby identifier; " +
- "make sure it starts with lowercase letter, " +
- "and is followed by any combination of letters, numbers and underscores."
+ OPTION_AS_ERROR_MESSAGE = "The value (%s) of the option `as` is not a valid Ruby identifier; " +
+ "make sure it starts with lowercase letter, " +
+ "and is followed by any combination of letters, numbers and underscores."
- def raise_invalid_identifier(path)
- raise ArgumentError.new(IDENTIFIER_ERROR_MESSAGE % (path))
- end
+ def raise_invalid_identifier(path)
+ raise ArgumentError.new(IDENTIFIER_ERROR_MESSAGE % (path))
+ end
- def raise_invalid_option_as(as)
- raise ArgumentError.new(OPTION_AS_ERROR_MESSAGE % (as))
- end
+ def raise_invalid_option_as(as)
+ raise ArgumentError.new(OPTION_AS_ERROR_MESSAGE % (as))
+ end
end
end
diff --git a/actionview/lib/action_view/renderer/streaming_template_renderer.rb b/actionview/lib/action_view/renderer/streaming_template_renderer.rb
index f38e2764d0..0323ebef6a 100644
--- a/actionview/lib/action_view/renderer/streaming_template_renderer.rb
+++ b/actionview/lib/action_view/renderer/streaming_template_renderer.rb
@@ -1,4 +1,4 @@
-require 'fiber'
+require "fiber"
module ActionView
# == TODO
@@ -29,15 +29,15 @@ module ActionView
# This is the same logging logic as in ShowExceptions middleware.
# TODO Once "exceptron" is in, refactor this piece to simply re-use exceptron.
- def log_error(exception) #:nodoc:
- logger = ActionView::Base.logger
- return unless logger
-
- message = "\n#{exception.class} (#{exception.message}):\n"
- message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code)
- message << " " << exception.backtrace.join("\n ")
- logger.fatal("#{message}\n\n")
- end
+ def log_error(exception) #:nodoc:
+ logger = ActionView::Base.logger
+ return unless logger
+
+ message = "\n#{exception.class} (#{exception.message}):\n"
+ message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code)
+ message << " " << exception.backtrace.join("\n ")
+ logger.fatal("#{message}\n\n")
+ end
end
# For streaming, instead of rendering a given a template, we return a Body
@@ -56,48 +56,48 @@ module ActionView
private
- def delayed_render(buffer, template, layout, view, locals)
- # Wrap the given buffer in the StreamingBuffer and pass it to the
- # underlying template handler. Now, every time something is concatenated
- # to the buffer, it is not appended to an array, but streamed straight
- # to the client.
- output = ActionView::StreamingBuffer.new(buffer)
- yielder = lambda { |*name| view._layout_for(*name) }
-
- instrument(:template, :identifier => template.identifier, :layout => layout.try(:virtual_path)) do
- fiber = Fiber.new do
- if layout
- layout.render(view, locals, output, &yielder)
- else
- # If you don't have a layout, just render the thing
- # and concatenate the final result. This is the same
- # as a layout with just <%= yield %>
- output.safe_concat view._layout_for
+ def delayed_render(buffer, template, layout, view, locals)
+ # Wrap the given buffer in the StreamingBuffer and pass it to the
+ # underlying template handler. Now, every time something is concatenated
+ # to the buffer, it is not appended to an array, but streamed straight
+ # to the client.
+ output = ActionView::StreamingBuffer.new(buffer)
+ yielder = lambda { |*name| view._layout_for(*name) }
+
+ instrument(:template, identifier: template.identifier, layout: layout.try(:virtual_path)) do
+ fiber = Fiber.new do
+ if layout
+ layout.render(view, locals, output, &yielder)
+ else
+ # If you don't have a layout, just render the thing
+ # and concatenate the final result. This is the same
+ # as a layout with just <%= yield %>
+ output.safe_concat view._layout_for
+ end
end
- end
- # Set the view flow to support streaming. It will be aware
- # when to stop rendering the layout because it needs to search
- # something in the template and vice-versa.
- view.view_flow = StreamingFlow.new(view, fiber)
+ # Set the view flow to support streaming. It will be aware
+ # when to stop rendering the layout because it needs to search
+ # something in the template and vice-versa.
+ view.view_flow = StreamingFlow.new(view, fiber)
- # Yo! Start the fiber!
- fiber.resume
+ # Yo! Start the fiber!
+ fiber.resume
- # If the fiber is still alive, it means we need something
- # from the template, so start rendering it. If not, it means
- # the layout exited without requiring anything from the template.
- if fiber.alive?
- content = template.render(view, locals, &yielder)
+ # If the fiber is still alive, it means we need something
+ # from the template, so start rendering it. If not, it means
+ # the layout exited without requiring anything from the template.
+ if fiber.alive?
+ content = template.render(view, locals, &yielder)
- # Once rendering the template is done, sets its content in the :layout key.
- view.view_flow.set(:layout, content)
+ # Once rendering the template is done, sets its content in the :layout key.
+ view.view_flow.set(:layout, content)
- # In case the layout continues yielding, we need to resume
- # the fiber until all yields are handled.
- fiber.resume while fiber.alive?
+ # In case the layout continues yielding, we need to resume
+ # the fiber until all yields are handled.
+ fiber.resume while fiber.alive?
+ end
end
end
- end
end
end
diff --git a/actionview/lib/action_view/renderer/template_renderer.rb b/actionview/lib/action_view/renderer/template_renderer.rb
index 9b106cd64a..0151653b73 100644
--- a/actionview/lib/action_view/renderer/template_renderer.rb
+++ b/actionview/lib/action_view/renderer/template_renderer.rb
@@ -1,4 +1,4 @@
-require 'active_support/core_ext/object/try'
+require "active_support/core_ext/object/try"
module ActionView
class TemplateRenderer < AbstractRenderer #:nodoc:
@@ -17,86 +17,86 @@ module ActionView
private
# Determine the template to be rendered using the given options.
- def determine_template(options)
- keys = options.has_key?(:locals) ? options[:locals].keys : []
+ def determine_template(options)
+ keys = options.has_key?(:locals) ? options[:locals].keys : []
- if options.key?(:body)
- Template::Text.new(options[:body])
- elsif options.key?(:text)
- Template::Text.new(options[:text], formats.first)
- elsif options.key?(:plain)
- Template::Text.new(options[:plain])
- elsif options.key?(:html)
- Template::HTML.new(options[:html], formats.first)
- elsif options.key?(:file)
- with_fallbacks { find_file(options[:file], nil, false, keys, @details) }
- elsif options.key?(:inline)
- handler = Template.handler_for_extension(options[:type] || "erb")
- Template.new(options[:inline], "inline template", handler, :locals => keys)
- elsif options.key?(:template)
- if options[:template].respond_to?(:render)
- options[:template]
+ if options.key?(:body)
+ Template::Text.new(options[:body])
+ elsif options.key?(:text)
+ Template::Text.new(options[:text], formats.first)
+ elsif options.key?(:plain)
+ Template::Text.new(options[:plain])
+ elsif options.key?(:html)
+ Template::HTML.new(options[:html], formats.first)
+ elsif options.key?(:file)
+ with_fallbacks { find_file(options[:file], nil, false, keys, @details) }
+ elsif options.key?(:inline)
+ handler = Template.handler_for_extension(options[:type] || "erb")
+ Template.new(options[:inline], "inline template", handler, locals: keys)
+ elsif options.key?(:template)
+ if options[:template].respond_to?(:render)
+ options[:template]
+ else
+ find_template(options[:template], options[:prefixes], false, keys, @details)
+ end
else
- find_template(options[:template], options[:prefixes], false, keys, @details)
+ raise ArgumentError, "You invoked render but did not give any of :partial, :template, :inline, :file, :plain, :html, :text or :body option."
end
- else
- raise ArgumentError, "You invoked render but did not give any of :partial, :template, :inline, :file, :plain, :html, :text or :body option."
end
- end
# Renders the given template. A string representing the layout can be
# supplied as well.
- def render_template(template, layout_name = nil, locals = nil) #:nodoc:
- view, locals = @view, locals || {}
+ def render_template(template, layout_name = nil, locals = nil) #:nodoc:
+ view, locals = @view, locals || {}
- render_with_layout(layout_name, locals) do |layout|
- instrument(:template, :identifier => template.identifier, :layout => layout.try(:virtual_path)) do
- template.render(view, locals) { |*name| view._layout_for(*name) }
+ render_with_layout(layout_name, locals) do |layout|
+ instrument(:template, identifier: template.identifier, layout: layout.try(:virtual_path)) do
+ template.render(view, locals) { |*name| view._layout_for(*name) }
+ end
end
end
- end
- def render_with_layout(path, locals) #:nodoc:
- layout = path && find_layout(path, locals.keys, [formats.first])
- content = yield(layout)
+ def render_with_layout(path, locals) #:nodoc:
+ layout = path && find_layout(path, locals.keys, [formats.first])
+ content = yield(layout)
- if layout
- view = @view
- view.view_flow.set(:layout, content)
- layout.render(view, locals){ |*name| view._layout_for(*name) }
- else
- content
+ if layout
+ view = @view
+ view.view_flow.set(:layout, content)
+ layout.render(view, locals){ |*name| view._layout_for(*name) }
+ else
+ content
+ end
end
- end
# This is the method which actually finds the layout using details in the lookup
# context object. If no layout is found, it checks if at least a layout with
# the given name exists across all details before raising the error.
- def find_layout(layout, keys, formats)
- resolve_layout(layout, keys, formats)
- end
+ def find_layout(layout, keys, formats)
+ resolve_layout(layout, keys, formats)
+ end
- def resolve_layout(layout, keys, formats)
- details = @details.dup
- details[:formats] = formats
+ def resolve_layout(layout, keys, formats)
+ details = @details.dup
+ details[:formats] = formats
- case layout
- when String
- begin
- if layout.start_with?('/')
- with_fallbacks { find_template(layout, nil, false, [], details) }
- else
- find_template(layout, nil, false, [], details)
+ case layout
+ when String
+ begin
+ if layout.start_with?("/")
+ with_fallbacks { find_template(layout, nil, false, [], details) }
+ else
+ find_template(layout, nil, false, [], details)
+ end
+ rescue ActionView::MissingTemplate
+ all_details = @details.merge(formats: @lookup_context.default_formats)
+ raise unless template_exists?(layout, nil, false, [], all_details)
end
- rescue ActionView::MissingTemplate
- all_details = @details.merge(:formats => @lookup_context.default_formats)
- raise unless template_exists?(layout, nil, false, [], all_details)
+ when Proc
+ resolve_layout(layout.call(formats), keys, formats)
+ else
+ layout
end
- when Proc
- resolve_layout(layout.call(formats), keys, formats)
- else
- layout
end
- end
end
end
diff --git a/actionview/lib/action_view/routing_url_for.rb b/actionview/lib/action_view/routing_url_for.rb
index 45e78d1ad9..669cffab1a 100644
--- a/actionview/lib/action_view/routing_url_for.rb
+++ b/actionview/lib/action_view/routing_url_for.rb
@@ -1,8 +1,7 @@
-require 'action_dispatch/routing/polymorphic_routes'
+require "action_dispatch/routing/polymorphic_routes"
module ActionView
module RoutingUrlFor
-
# Returns the URL for the set of +options+ provided. This takes the
# same options as +url_for+ in Action Controller (see the
# documentation for <tt>ActionController::Base#url_for</tt>). Note that by default
diff --git a/actionview/lib/action_view/tasks/cache_digests.rake b/actionview/lib/action_view/tasks/cache_digests.rake
index 045bdf5691..d30b3f7797 100644
--- a/actionview/lib/action_view/tasks/cache_digests.rake
+++ b/actionview/lib/action_view/tasks/cache_digests.rake
@@ -1,19 +1,19 @@
namespace :cache_digests do
- desc 'Lookup nested dependencies for TEMPLATE (like messages/show or comments/_comment.html)'
- task :nested_dependencies => :environment do
- abort 'You must provide TEMPLATE for the task to run' unless ENV['TEMPLATE'].present?
+ desc "Lookup nested dependencies for TEMPLATE (like messages/show or comments/_comment.html)"
+ task nested_dependencies: :environment do
+ abort "You must provide TEMPLATE for the task to run" unless ENV["TEMPLATE"].present?
puts JSON.pretty_generate ActionView::Digestor.tree(CacheDigests.template_name, CacheDigests.finder).children.map(&:to_dep_map)
end
- desc 'Lookup first-level dependencies for TEMPLATE (like messages/show or comments/_comment.html)'
- task :dependencies => :environment do
- abort 'You must provide TEMPLATE for the task to run' unless ENV['TEMPLATE'].present?
+ desc "Lookup first-level dependencies for TEMPLATE (like messages/show or comments/_comment.html)"
+ task dependencies: :environment do
+ abort "You must provide TEMPLATE for the task to run" unless ENV["TEMPLATE"].present?
puts JSON.pretty_generate ActionView::Digestor.tree(CacheDigests.template_name, CacheDigests.finder).children.map(&:name)
end
class CacheDigests
def self.template_name
- ENV['TEMPLATE'].split('.', 2).first
+ ENV["TEMPLATE"].split(".", 2).first
end
def self.finder
diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb
index 169ee55fdc..1f90cae75b 100644
--- a/actionview/lib/action_view/template.rb
+++ b/actionview/lib/action_view/template.rb
@@ -1,6 +1,6 @@
-require 'active_support/core_ext/object/try'
-require 'active_support/core_ext/kernel/singleton_class'
-require 'thread'
+require "active_support/core_ext/object/try"
+require "active_support/core_ext/kernel/singleton_class"
+require "thread"
module ActionView
# = Action View Template
@@ -180,12 +180,12 @@ module ActionView
name = pieces.pop
partial = !!name.sub!(/^_/, "")
lookup.disable_cache do
- lookup.find_template(name, [ pieces.join('/') ], partial, @locals)
+ lookup.find_template(name, [ pieces.join("/") ], partial, @locals)
end
end
def inspect
- @inspect ||= defined?(Rails.root) ? identifier.sub("#{Rails.root}/", ''.freeze) : identifier
+ @inspect ||= defined?(Rails.root) ? identifier.sub("#{Rails.root}/", "".freeze) : identifier
end
# This method is responsible for properly setting the encoding of the
@@ -204,7 +204,7 @@ module ActionView
# Look for # encoding: *. If we find one, we'll encode the
# String in that encoding, otherwise, we'll use the
# default external encoding.
- if source.sub!(/\A#{ENCODING_FLAG}/, '')
+ if source.sub!(/\A#{ENCODING_FLAG}/, "")
encoding = magic_encoding = $1
else
encoding = Encoding.default_external
@@ -326,19 +326,19 @@ module ActionView
def locals_code #:nodoc:
# Double assign to suppress the dreaded 'assigned but unused variable' warning
- @locals.each_with_object('') { |key, code| code << "#{key} = #{key} = local_assigns[:#{key}];" }
+ @locals.each_with_object("") { |key, code| code << "#{key} = #{key} = local_assigns[:#{key}];" }
end
def method_name #:nodoc:
@method_name ||= begin
m = "_#{identifier_method_name}__#{@identifier.hash}_#{__id__}"
- m.tr!('-'.freeze, '_'.freeze)
+ m.tr!("-".freeze, "_".freeze)
m
end
end
def identifier_method_name #:nodoc:
- inspect.tr('^a-z_'.freeze, '_'.freeze)
+ inspect.tr("^a-z_".freeze, "_".freeze)
end
def instrument(action, &block)
diff --git a/actionview/lib/action_view/template/error.rb b/actionview/lib/action_view/template/error.rb
index 0f1348b032..b95e5236a0 100644
--- a/actionview/lib/action_view/template/error.rb
+++ b/actionview/lib/action_view/template/error.rb
@@ -1,5 +1,5 @@
require "active_support/core_ext/enumerable"
-require 'active_support/core_ext/regexp'
+require "active_support/core_ext/regexp"
module ActionView
# = Action View Errors
@@ -37,9 +37,9 @@ module ActionView
template_type = if partial
"partial"
elsif /layouts/i.match?(path)
- 'layout'
+ "layout"
else
- 'template'
+ "template"
end
if partial && path.present?
@@ -131,7 +131,7 @@ module ActionView
if line_number
"on line ##{line_number} of "
else
- 'in '
+ "in "
end + file_name
end
diff --git a/actionview/lib/action_view/template/handlers.rb b/actionview/lib/action_view/template/handlers.rb
index ad4c353608..f4301f6f07 100644
--- a/actionview/lib/action_view/template/handlers.rb
+++ b/actionview/lib/action_view/template/handlers.rb
@@ -2,10 +2,10 @@ module ActionView #:nodoc:
# = Action View Template Handlers
class Template
module Handlers #:nodoc:
- autoload :Raw, 'action_view/template/handlers/raw'
- autoload :ERB, 'action_view/template/handlers/erb'
- autoload :Html, 'action_view/template/handlers/html'
- autoload :Builder, 'action_view/template/handlers/builder'
+ autoload :Raw, "action_view/template/handlers/raw"
+ autoload :ERB, "action_view/template/handlers/erb"
+ autoload :Html, "action_view/template/handlers/html"
+ autoload :Builder, "action_view/template/handlers/builder"
def self.extended(base)
base.register_default_template_handler :raw, Raw.new
diff --git a/actionview/lib/action_view/template/handlers/builder.rb b/actionview/lib/action_view/template/handlers/builder.rb
index d90b0c6378..e08a5b5db8 100644
--- a/actionview/lib/action_view/template/handlers/builder.rb
+++ b/actionview/lib/action_view/template/handlers/builder.rb
@@ -15,12 +15,12 @@ module ActionView
protected
- def require_engine
- @required ||= begin
- require "builder"
- true
+ def require_engine
+ @required ||= begin
+ require "builder"
+ true
+ end
end
- end
end
end
end
diff --git a/actionview/lib/action_view/template/handlers/erb.rb b/actionview/lib/action_view/template/handlers/erb.rb
index 058b590c56..6f07de1813 100644
--- a/actionview/lib/action_view/template/handlers/erb.rb
+++ b/actionview/lib/action_view/template/handlers/erb.rb
@@ -1,5 +1,5 @@
-require 'erubis'
-require 'active_support/core_ext/regexp'
+require "erubis"
+require "active_support/core_ext/regexp"
module ActionView
class Template
@@ -29,7 +29,7 @@ module ActionView
# We override to always treat <%== as escaped.
def add_expr(src, code, indicator)
case indicator
- when '=='
+ when "=="
add_expr_escaped(src, code)
else
super
@@ -41,9 +41,9 @@ module ActionView
def add_expr_literal(src, code)
flush_newline_if_pending(src)
if BLOCK_EXPR.match?(code)
- src << '@output_buffer.append= ' << code
+ src << "@output_buffer.append= " << code
else
- src << '@output_buffer.append=(' << code << ');'
+ src << "@output_buffer.append=(" << code << ");"
end
end
@@ -63,7 +63,7 @@ module ActionView
def add_postamble(src)
flush_newline_if_pending(src)
- src << '@output_buffer.to_s'
+ src << "@output_buffer.to_s"
end
def flush_newline_if_pending(src)
@@ -78,7 +78,7 @@ module ActionView
# Specify trim mode for the ERB compiler. Defaults to '-'.
# See ERB documentation for suitable values.
class_attribute :erb_trim_mode
- self.erb_trim_mode = '-'
+ self.erb_trim_mode = "-"
# Default implementation used.
class_attribute :erb_implementation
@@ -109,7 +109,7 @@ module ActionView
# expression
template_source = template.source.dup.force_encoding(Encoding::ASCII_8BIT)
- erb = template_source.gsub(ENCODING_TAG, '')
+ erb = template_source.gsub(ENCODING_TAG, "")
encoding = $2
erb.force_encoding valid_encoding(template.source.dup, encoding)
@@ -119,8 +119,8 @@ module ActionView
self.class.erb_implementation.new(
erb,
- :escape => (self.class.escape_whitelist.include? template.type),
- :trim => (self.class.erb_trim_mode == "-")
+ escape: (self.class.escape_whitelist.include? template.type),
+ trim: (self.class.erb_trim_mode == "-")
).src
end
diff --git a/actionview/lib/action_view/template/html.rb b/actionview/lib/action_view/template/html.rb
index 0321f819b5..ddbd2ea36a 100644
--- a/actionview/lib/action_view/template/html.rb
+++ b/actionview/lib/action_view/template/html.rb
@@ -11,11 +11,11 @@ module ActionView #:nodoc:
end
def identifier
- 'html template'
+ "html template"
end
def inspect
- 'html template'
+ "html template"
end
def to_str
diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb
index bf68e93c58..33d60be144 100644
--- a/actionview/lib/action_view/template/resolver.rb
+++ b/actionview/lib/action_view/template/resolver.rb
@@ -37,7 +37,7 @@ module ActionView
class Cache #:nodoc:
class SmallCache < Concurrent::Map
def initialize(options = {})
- super(options.merge(:initial_capacity => 2))
+ super(options.merge(initial_capacity: 2))
end
end
@@ -107,22 +107,22 @@ module ActionView
private
- def canonical_no_templates(templates)
- templates.empty? ? NO_TEMPLATES : templates
- end
-
- def templates_have_changed?(cached_templates, fresh_templates)
- # if either the old or new template list is empty, we don't need to (and can't)
- # compare modification times, and instead just check whether the lists are different
- if cached_templates.blank? || fresh_templates.blank?
- return fresh_templates.blank? != cached_templates.blank?
+ def canonical_no_templates(templates)
+ templates.empty? ? NO_TEMPLATES : templates
end
- cached_templates_max_updated_at = cached_templates.map(&:updated_at).max
+ def templates_have_changed?(cached_templates, fresh_templates)
+ # if either the old or new template list is empty, we don't need to (and can't)
+ # compare modification times, and instead just check whether the lists are different
+ if cached_templates.blank? || fresh_templates.blank?
+ return fresh_templates.blank? != cached_templates.blank?
+ end
- # if a template has changed, it will be now be newer than all the cached templates
- fresh_templates.any? { |t| t.updated_at > cached_templates_max_updated_at }
- end
+ cached_templates_max_updated_at = cached_templates.map(&:updated_at).max
+
+ # if a template has changed, it will be now be newer than all the cached templates
+ fresh_templates.any? { |t| t.updated_at > cached_templates_max_updated_at }
+ end
end
cattr_accessor :caching
@@ -204,7 +204,7 @@ module ActionView
# An abstract class that implements a Resolver with path semantics.
class PathResolver < Resolver #:nodoc:
- EXTENSIONS = { :locale => ".", :formats => ".", :variants => "+", :handlers => "." }
+ EXTENSIONS = { locale: ".", formats: ".", variants: "+", handlers: "." }
DEFAULT_PATTERN = ":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}"
def initialize(pattern=nil)
@@ -214,93 +214,93 @@ module ActionView
private
- def find_templates(name, prefix, partial, details, outside_app_allowed = false)
- path = Path.build(name, prefix, partial)
- query(path, details, details[:formats], outside_app_allowed)
- end
+ def find_templates(name, prefix, partial, details, outside_app_allowed = false)
+ path = Path.build(name, prefix, partial)
+ query(path, details, details[:formats], outside_app_allowed)
+ end
- def query(path, details, formats, outside_app_allowed)
- query = build_query(path, details)
+ def query(path, details, formats, outside_app_allowed)
+ query = build_query(path, details)
- template_paths = find_template_paths(query)
- template_paths = reject_files_external_to_app(template_paths) unless outside_app_allowed
+ template_paths = find_template_paths(query)
+ template_paths = reject_files_external_to_app(template_paths) unless outside_app_allowed
- template_paths.map do |template|
- handler, format, variant = extract_handler_and_format_and_variant(template, formats)
- contents = File.binread(template)
+ template_paths.map do |template|
+ handler, format, variant = extract_handler_and_format_and_variant(template, formats)
+ contents = File.binread(template)
- Template.new(contents, File.expand_path(template), handler,
- :virtual_path => path.virtual,
- :format => format,
- :variant => variant,
- :updated_at => mtime(template)
- )
+ Template.new(contents, File.expand_path(template), handler,
+ virtual_path: path.virtual,
+ format: format,
+ variant: variant,
+ updated_at: mtime(template)
+ )
+ end
end
- end
- def reject_files_external_to_app(files)
- files.reject { |filename| !inside_path?(@path, filename) }
- end
+ def reject_files_external_to_app(files)
+ files.reject { |filename| !inside_path?(@path, filename) }
+ end
- def find_template_paths(query)
- Dir[query].uniq.reject do |filename|
- File.directory?(filename) ||
- # deals with case-insensitive file systems.
- !File.fnmatch(query, filename, File::FNM_EXTGLOB)
+ def find_template_paths(query)
+ Dir[query].uniq.reject do |filename|
+ File.directory?(filename) ||
+ # deals with case-insensitive file systems.
+ !File.fnmatch(query, filename, File::FNM_EXTGLOB)
+ end
end
- end
- def inside_path?(path, filename)
- filename = File.expand_path(filename)
- path = File.join(path, '')
- filename.start_with?(path)
- end
+ def inside_path?(path, filename)
+ filename = File.expand_path(filename)
+ path = File.join(path, "")
+ filename.start_with?(path)
+ end
# Helper for building query glob string based on resolver's pattern.
- def build_query(path, details)
- query = @pattern.dup
+ def build_query(path, details)
+ query = @pattern.dup
- prefix = path.prefix.empty? ? '' : "#{escape_entry(path.prefix)}\\1"
- query.gsub!(/:prefix(\/)?/, prefix)
+ prefix = path.prefix.empty? ? "" : "#{escape_entry(path.prefix)}\\1"
+ query.gsub!(/:prefix(\/)?/, prefix)
- partial = escape_entry(path.partial? ? "_#{path.name}" : path.name)
- query.gsub!(/:action/, partial)
+ partial = escape_entry(path.partial? ? "_#{path.name}" : path.name)
+ query.gsub!(/:action/, partial)
- details.each do |ext, candidates|
- if ext == :variants && candidates == :any
- query.gsub!(/:#{ext}/, "*")
- else
- query.gsub!(/:#{ext}/, "{#{candidates.compact.uniq.join(',')}}")
+ details.each do |ext, candidates|
+ if ext == :variants && candidates == :any
+ query.gsub!(/:#{ext}/, "*")
+ else
+ query.gsub!(/:#{ext}/, "{#{candidates.compact.uniq.join(',')}}")
+ end
end
- end
- File.expand_path(query, @path)
- end
+ File.expand_path(query, @path)
+ end
- def escape_entry(entry)
- entry.gsub(/[*?{}\[\]]/, '\\\\\\&'.freeze)
- end
+ def escape_entry(entry)
+ entry.gsub(/[*?{}\[\]]/, '\\\\\\&'.freeze)
+ end
# Returns the file mtime from the filesystem.
- def mtime(p)
- File.mtime(p)
- end
+ def mtime(p)
+ File.mtime(p)
+ end
# Extract handler, formats and variant from path. If a format cannot be found neither
# from the path, or the handler, we should return the array of formats given
# to the resolver.
- def extract_handler_and_format_and_variant(path, default_formats)
- pieces = File.basename(path).split('.'.freeze)
- pieces.shift
+ def extract_handler_and_format_and_variant(path, default_formats)
+ pieces = File.basename(path).split(".".freeze)
+ pieces.shift
- extension = pieces.pop
+ extension = pieces.pop
- handler = Template.handler_for_extension(extension)
- format, variant = pieces.last.split(EXTENSIONS[:variants], 2) if pieces.last
- format &&= Template::Types[format]
+ handler = Template.handler_for_extension(extension)
+ format, variant = pieces.last.split(EXTENSIONS[:variants], 2) if pieces.last
+ format &&= Template::Types[format]
- [handler, format, variant]
- end
+ [handler, format, variant]
+ end
end
# A resolver that loads files from the filesystem. It allows setting your own
diff --git a/actionview/lib/action_view/template/text.rb b/actionview/lib/action_view/template/text.rb
index 04f5b8d17a..898593e702 100644
--- a/actionview/lib/action_view/template/text.rb
+++ b/actionview/lib/action_view/template/text.rb
@@ -11,11 +11,11 @@ module ActionView #:nodoc:
end
def identifier
- 'text template'
+ "text template"
end
def inspect
- 'text template'
+ "text template"
end
def to_str
diff --git a/actionview/lib/action_view/template/types.rb b/actionview/lib/action_view/template/types.rb
index b32567cd66..21959a3798 100644
--- a/actionview/lib/action_view/template/types.rb
+++ b/actionview/lib/action_view/template/types.rb
@@ -1,4 +1,4 @@
-require 'active_support/core_ext/module/attribute_accessors'
+require "active_support/core_ext/module/attribute_accessors"
module ActionView
class Template
diff --git a/actionview/lib/action_view/test_case.rb b/actionview/lib/action_view/test_case.rb
index 120962b5aa..42fa17d1e0 100644
--- a/actionview/lib/action_view/test_case.rb
+++ b/actionview/lib/action_view/test_case.rb
@@ -1,9 +1,9 @@
-require 'active_support/core_ext/module/remove_method'
-require 'action_controller'
-require 'action_controller/test_case'
-require 'action_view'
+require "active_support/core_ext/module/remove_method"
+require "action_controller"
+require "action_controller/test_case"
+require "action_view"
-require 'rails-dom-testing'
+require "rails-dom-testing"
module ActionView
# = Action View Test Case
@@ -27,7 +27,7 @@ module ActionView
@request = ActionController::TestRequest.create
@response = ActionDispatch::TestResponse.new
- @request.env.delete('PATH_INFO')
+ @request.env.delete("PATH_INFO")
@params = ActionController::Parameters.new
end
end
@@ -49,7 +49,7 @@ module ActionView
include ActiveSupport::Testing::ConstantLookup
- delegate :lookup_context, :to => :controller
+ delegate :lookup_context, to: :controller
attr_accessor :controller, :output_buffer, :rendered
module ClassMethods
@@ -96,7 +96,6 @@ module ActionView
helper(helper_class) if helper_class
include _helpers
end
-
end
def setup_with_controller
@@ -104,8 +103,8 @@ module ActionView
@request = @controller.request
# empty string ensures buffer has UTF-8 encoding as
# new without arguments returns ASCII-8BIT encoded buffer like String#new
- @output_buffer = ActiveSupport::SafeBuffer.new ''
- @rendered = ''
+ @output_buffer = ActiveSupport::SafeBuffer.new ""
+ @rendered = ""
make_test_case_available_to_view!
say_no_to_protect_against_forgery!
diff --git a/actionview/lib/action_view/testing/resolvers.rb b/actionview/lib/action_view/testing/resolvers.rb
index 982ecf9efc..1a92dd71b1 100644
--- a/actionview/lib/action_view/testing/resolvers.rb
+++ b/actionview/lib/action_view/testing/resolvers.rb
@@ -1,5 +1,5 @@
-require 'active_support/core_ext/regexp'
-require 'action_view/template/resolver'
+require "active_support/core_ext/regexp"
+require "action_view/template/resolver"
module ActionView #:nodoc:
# Use FixtureResolver in your tests to simulate the presence of files on the
@@ -15,7 +15,7 @@ module ActionView #:nodoc:
end
def to_s
- @hash.keys.join(', ')
+ @hash.keys.join(", ")
end
private
@@ -23,7 +23,7 @@ module ActionView #:nodoc:
def query(path, exts, formats, _)
query = ""
EXTENSIONS.each_key do |ext|
- query << '(' << exts[ext].map {|e| e && Regexp.escape(".#{e}") }.join('|') << '|)'
+ query << "(" << exts[ext].map {|e| e && Regexp.escape(".#{e}") }.join("|") << "|)"
end
query = /^(#{Regexp.escape(path)})#{query}$/
@@ -33,10 +33,10 @@ module ActionView #:nodoc:
next unless query.match?(_path)
handler, format, variant = extract_handler_and_format_and_variant(_path, formats)
templates << Template.new(source, _path, handler,
- :virtual_path => path.virtual,
- :format => format,
- :variant => variant,
- :updated_at => updated_at
+ virtual_path: path.virtual,
+ format: format,
+ variant: variant,
+ updated_at: updated_at
)
end
@@ -47,7 +47,7 @@ module ActionView #:nodoc:
class NullResolver < PathResolver
def query(path, exts, formats, _)
handler, format, variant = extract_handler_and_format_and_variant(path, formats)
- [ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, :virtual_path => path.virtual, :format => format, :variant => variant)]
+ [ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, virtual_path: path.virtual, format: format, variant: variant)]
end
end
end
diff --git a/actionview/lib/action_view/version.rb b/actionview/lib/action_view/version.rb
index f55d3fdaef..315404864d 100644
--- a/actionview/lib/action_view/version.rb
+++ b/actionview/lib/action_view/version.rb
@@ -1,4 +1,4 @@
-require_relative 'gem_version'
+require_relative "gem_version"
module ActionView
# Returns the version of the currently loaded ActionView as a <tt>Gem::Version</tt>
diff --git a/actionview/lib/action_view/view_paths.rb b/actionview/lib/action_view/view_paths.rb
index 717d6866c5..6b6cbcf06a 100644
--- a/actionview/lib/action_view/view_paths.rb
+++ b/actionview/lib/action_view/view_paths.rb
@@ -9,7 +9,7 @@ module ActionView
end
delegate :template_exists?, :any_templates?, :view_paths, :formats, :formats=,
- :locale, :locale=, :to => :lookup_context
+ :locale, :locale=, to: :lookup_context
module ClassMethods
def _prefixes # :nodoc:
@@ -24,9 +24,9 @@ module ActionView
# Override this method in your controller if you want to change paths prefixes for finding views.
# Prefixes defined here will still be added to parents' <tt>._prefixes</tt>.
- def local_prefixes
- [controller_path]
- end
+ def local_prefixes
+ [controller_path]
+ end
end
# The prefixes used in render "foo" shortcuts.