actionview 5.0.7.2 → 5.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionview might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/CHANGELOG.md +92 -384
- data/MIT-LICENSE +1 -1
- data/README.rdoc +1 -1
- data/lib/action_view.rb +5 -5
- data/lib/action_view/base.rb +19 -19
- data/lib/action_view/buffers.rb +1 -1
- data/lib/action_view/context.rb +1 -1
- data/lib/action_view/dependency_tracker.rb +4 -5
- data/lib/action_view/digestor.rb +6 -7
- data/lib/action_view/flows.rb +5 -6
- data/lib/action_view/gem_version.rb +3 -3
- data/lib/action_view/helpers.rb +1 -1
- data/lib/action_view/helpers/active_model_helper.rb +8 -8
- data/lib/action_view/helpers/asset_tag_helper.rb +62 -36
- data/lib/action_view/helpers/asset_url_helper.rb +111 -49
- data/lib/action_view/helpers/atom_feed_helper.rb +12 -13
- data/lib/action_view/helpers/cache_helper.rb +34 -20
- data/lib/action_view/helpers/capture_helper.rb +2 -2
- data/lib/action_view/helpers/controller_helper.rb +3 -11
- data/lib/action_view/helpers/csrf_helper.rb +3 -3
- data/lib/action_view/helpers/date_helper.rb +109 -107
- data/lib/action_view/helpers/debug_helper.rb +2 -3
- data/lib/action_view/helpers/form_helper.rb +406 -31
- data/lib/action_view/helpers/form_options_helper.rb +12 -12
- data/lib/action_view/helpers/form_tag_helper.rb +19 -18
- data/lib/action_view/helpers/javascript_helper.rb +6 -6
- data/lib/action_view/helpers/number_helper.rb +48 -46
- data/lib/action_view/helpers/output_safety_helper.rb +8 -8
- data/lib/action_view/helpers/rendering_helper.rb +2 -2
- data/lib/action_view/helpers/sanitize_helper.rb +6 -8
- data/lib/action_view/helpers/tag_helper.rb +194 -77
- data/lib/action_view/helpers/tags/base.rb +121 -102
- data/lib/action_view/helpers/tags/check_box.rb +17 -17
- data/lib/action_view/helpers/tags/collection_check_boxes.rb +8 -8
- data/lib/action_view/helpers/tags/collection_helpers.rb +60 -60
- data/lib/action_view/helpers/tags/collection_radio_buttons.rb +2 -2
- data/lib/action_view/helpers/tags/collection_select.rb +2 -2
- data/lib/action_view/helpers/tags/date_select.rb +36 -36
- data/lib/action_view/helpers/tags/grouped_collection_select.rb +2 -2
- data/lib/action_view/helpers/tags/label.rb +4 -0
- data/lib/action_view/helpers/tags/password_field.rb +1 -1
- data/lib/action_view/helpers/tags/radio_button.rb +4 -4
- data/lib/action_view/helpers/tags/select.rb +9 -9
- data/lib/action_view/helpers/tags/text_area.rb +1 -1
- data/lib/action_view/helpers/tags/text_field.rb +5 -5
- data/lib/action_view/helpers/tags/translator.rb +14 -12
- data/lib/action_view/helpers/text_helper.rb +20 -19
- data/lib/action_view/helpers/translation_helper.rb +6 -6
- data/lib/action_view/helpers/url_helper.rb +42 -38
- data/lib/action_view/layouts.rb +51 -47
- data/lib/action_view/log_subscriber.rb +24 -9
- data/lib/action_view/lookup_context.rb +19 -25
- data/lib/action_view/path_set.rb +19 -19
- data/lib/action_view/railtie.rb +3 -3
- data/lib/action_view/record_identifier.rb +6 -6
- data/lib/action_view/renderer/abstract_renderer.rb +17 -17
- data/lib/action_view/renderer/partial_renderer.rb +188 -187
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +7 -1
- data/lib/action_view/renderer/streaming_template_renderer.rb +45 -47
- data/lib/action_view/renderer/template_renderer.rb +64 -66
- data/lib/action_view/rendering.rb +4 -5
- data/lib/action_view/routing_url_for.rb +9 -13
- data/lib/action_view/tasks/cache_digests.rake +7 -7
- data/lib/action_view/template.rb +26 -27
- data/lib/action_view/template/error.rb +5 -15
- data/lib/action_view/template/handlers.rb +4 -4
- data/lib/action_view/template/handlers/builder.rb +7 -7
- data/lib/action_view/template/handlers/erb.rb +9 -76
- data/lib/action_view/template/handlers/erb/deprecated_erubis.rb +9 -0
- data/lib/action_view/template/handlers/erb/erubi.rb +81 -0
- data/lib/action_view/template/handlers/erb/erubis.rb +81 -0
- data/lib/action_view/template/html.rb +2 -4
- data/lib/action_view/template/resolver.rb +107 -90
- data/lib/action_view/template/text.rb +5 -8
- data/lib/action_view/template/types.rb +1 -1
- data/lib/action_view/test_case.rb +20 -21
- data/lib/action_view/testing/resolvers.rb +29 -30
- data/lib/action_view/version.rb +1 -1
- data/lib/action_view/view_paths.rb +20 -8
- data/lib/assets/compiled/rails-ujs.js +648 -0
- metadata +19 -14
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "action_view/helpers/tags/collection_helpers"
|
2
2
|
|
3
3
|
module ActionView
|
4
4
|
module Helpers
|
@@ -7,7 +7,7 @@ module ActionView
|
|
7
7
|
include CollectionHelpers
|
8
8
|
|
9
9
|
class RadioButtonBuilder < Builder # :nodoc:
|
10
|
-
def radio_button(extra_html_options={})
|
10
|
+
def radio_button(extra_html_options = {})
|
11
11
|
html_options = extra_html_options.merge(@input_html_options)
|
12
12
|
@template_object.radio_button(@object_name, @method_name, @value, html_options)
|
13
13
|
end
|
@@ -13,8 +13,8 @@ module ActionView
|
|
13
13
|
|
14
14
|
def render
|
15
15
|
option_tags_options = {
|
16
|
-
:
|
17
|
-
:
|
16
|
+
selected: @options.fetch(:selected) { value(@object) },
|
17
|
+
disabled: @options[:disabled]
|
18
18
|
}
|
19
19
|
|
20
20
|
select_content_tag(
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "active_support/core_ext/time/calculations"
|
2
2
|
|
3
3
|
module ActionView
|
4
4
|
module Helpers
|
@@ -16,56 +16,56 @@ module ActionView
|
|
16
16
|
|
17
17
|
class << self
|
18
18
|
def select_type
|
19
|
-
@select_type ||=
|
19
|
+
@select_type ||= name.split("::").last.sub("Select", "").downcase
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
def select_type
|
26
|
+
self.class.select_type
|
27
|
+
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
def datetime_selector(options, html_options)
|
30
|
+
datetime = options.fetch(:selected) { value(object) || default_datetime(options) }
|
31
|
+
@auto_index ||= nil
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
options = options.dup
|
34
|
+
options[:field_name] = @method_name
|
35
|
+
options[:include_position] = true
|
36
|
+
options[:prefix] ||= @object_name
|
37
|
+
options[:index] = @auto_index if @auto_index && !options.has_key?(:index)
|
38
38
|
|
39
|
-
|
40
|
-
|
39
|
+
DateTimeSelector.new(datetime, options, html_options)
|
40
|
+
end
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
def default_datetime(options)
|
43
|
+
return if options[:include_blank] || options[:prompt]
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
case options[:default]
|
46
|
+
when nil
|
47
|
+
Time.current
|
48
|
+
when Date, Time
|
49
|
+
options[:default]
|
50
|
+
else
|
51
|
+
default = options[:default].dup
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
# Rename :minute and :second to :min and :sec
|
54
|
+
default[:min] ||= default[:minute]
|
55
|
+
default[:sec] ||= default[:second]
|
56
56
|
|
57
|
-
|
57
|
+
time = Time.current
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
[:year, :month, :day, :hour, :min, :sec].each do |key|
|
60
|
+
default[key] ||= time.send(key)
|
61
|
+
end
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
63
|
+
Time.utc(
|
64
|
+
default[:year], default[:month], default[:day],
|
65
|
+
default[:hour], default[:min], default[:sec]
|
66
|
+
)
|
67
|
+
end
|
67
68
|
end
|
68
|
-
end
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
@@ -15,8 +15,8 @@ module ActionView
|
|
15
15
|
|
16
16
|
def render
|
17
17
|
option_tags_options = {
|
18
|
-
:
|
19
|
-
:
|
18
|
+
selected: @options.fetch(:selected) { value(@object) },
|
19
|
+
disabled: @options[:disabled]
|
20
20
|
}
|
21
21
|
|
22
22
|
select_content_tag(
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "action_view/helpers/tags/checkable"
|
2
2
|
|
3
3
|
module ActionView
|
4
4
|
module Helpers
|
@@ -22,9 +22,9 @@ module ActionView
|
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
def checked?(value)
|
26
|
+
value.to_s == @tag_value.to_s
|
27
|
+
end
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -13,8 +13,8 @@ module ActionView
|
|
13
13
|
|
14
14
|
def render
|
15
15
|
option_tags_options = {
|
16
|
-
:
|
17
|
-
:
|
16
|
+
selected: @options.fetch(:selected) { value(@object) },
|
17
|
+
disabled: @options[:disabled]
|
18
18
|
}
|
19
19
|
|
20
20
|
option_tags = if grouped_choices?
|
@@ -28,13 +28,13 @@ module ActionView
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
# Grouped choices look like this:
|
32
|
+
#
|
33
|
+
# [nil, []]
|
34
|
+
# { nil => [] }
|
35
|
+
def grouped_choices?
|
36
|
+
!@choices.empty? && @choices.first.respond_to?(:last) && Array === @choices.first.last
|
37
|
+
end
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "action_view/helpers/tags/placeholderable"
|
2
2
|
|
3
3
|
module ActionView
|
4
4
|
module Helpers
|
@@ -17,15 +17,15 @@ module ActionView
|
|
17
17
|
|
18
18
|
class << self
|
19
19
|
def field_type
|
20
|
-
@field_type ||=
|
20
|
+
@field_type ||= name.split("::").last.sub("Field", "").downcase
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
def field_type
|
27
|
+
self.class.field_type
|
28
|
+
end
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -14,26 +14,28 @@ module ActionView
|
|
14
14
|
translated_attribute || human_attribute_name
|
15
15
|
end
|
16
16
|
|
17
|
+
# TODO Change this to private once we've dropped Ruby 2.2 support.
|
18
|
+
# Workaround for Ruby 2.2 "private attribute?" warning.
|
17
19
|
protected
|
18
20
|
|
19
|
-
|
21
|
+
attr_reader :object_name, :method_and_value, :scope, :model
|
20
22
|
|
21
23
|
private
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
def i18n_default
|
26
|
+
if model
|
27
|
+
key = model.model_name.i18n_key
|
28
|
+
["#{key}.#{method_and_value}".to_sym, ""]
|
29
|
+
else
|
30
|
+
""
|
31
|
+
end
|
29
32
|
end
|
30
|
-
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
def human_attribute_name
|
35
|
+
if model && model.class.respond_to?(:human_attribute_name)
|
36
|
+
model.class.human_attribute_name(method_and_value)
|
37
|
+
end
|
35
38
|
end
|
36
|
-
end
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "active_support/core_ext/string/filters"
|
2
|
+
require "active_support/core_ext/array/extract_options"
|
3
3
|
|
4
4
|
module ActionView
|
5
5
|
# = Action View Text Helpers
|
@@ -135,7 +135,7 @@ module ActionView
|
|
135
135
|
else
|
136
136
|
match = Array(phrases).map do |p|
|
137
137
|
Regexp === p ? p.to_s : Regexp.escape(p)
|
138
|
-
end.join(
|
138
|
+
end.join("|")
|
139
139
|
|
140
140
|
if block_given?
|
141
141
|
text.gsub(/(#{match})(?![^<]*?>)/i) { |found| yield found }
|
@@ -151,7 +151,7 @@ module ActionView
|
|
151
151
|
# defined in <tt>:radius</tt> (which defaults to 100). If the excerpt radius overflows the beginning or end of the +text+,
|
152
152
|
# then the <tt>:omission</tt> option (which defaults to "...") will be prepended/appended accordingly. Use the
|
153
153
|
# <tt>:separator</tt> option to choose the delimitation. The resulting string will be stripped in any case. If the +phrase+
|
154
|
-
# isn't found, nil is returned.
|
154
|
+
# isn't found, +nil+ is returned.
|
155
155
|
#
|
156
156
|
# excerpt('This is an example', 'an', radius: 5)
|
157
157
|
# # => ...s is an exam...
|
@@ -187,7 +187,7 @@ module ActionView
|
|
187
187
|
unless separator.empty?
|
188
188
|
text.split(separator).each do |value|
|
189
189
|
if value.match(regex)
|
190
|
-
|
190
|
+
phrase = value
|
191
191
|
break
|
192
192
|
end
|
193
193
|
end
|
@@ -262,10 +262,11 @@ module ActionView
|
|
262
262
|
end
|
263
263
|
|
264
264
|
# Returns +text+ transformed into HTML using simple formatting rules.
|
265
|
-
# Two or more consecutive newlines(<tt>\n\n</tt>) are
|
266
|
-
# paragraph and wrapped in <tt><p></tt> tags. One newline
|
267
|
-
#
|
268
|
-
# method does not remove the
|
265
|
+
# Two or more consecutive newlines(<tt>\n\n</tt> or <tt>\r\n\r\n</tt>) are
|
266
|
+
# considered a paragraph and wrapped in <tt><p></tt> tags. One newline
|
267
|
+
# (<tt>\n</tt> or <tt>\r\n</tt>) is considered a linebreak and a
|
268
|
+
# <tt><br /></tt> tag is appended. This method does not remove the
|
269
|
+
# newlines from the +text+.
|
269
270
|
#
|
270
271
|
# You can pass any HTML attributes into <tt>html_options</tt>. These
|
271
272
|
# will be added to all created paragraphs.
|
@@ -350,7 +351,7 @@ module ActionView
|
|
350
351
|
# <% end %>
|
351
352
|
def cycle(first_value, *values)
|
352
353
|
options = values.extract_options!
|
353
|
-
name = options.fetch(:name,
|
354
|
+
name = options.fetch(:name, "default")
|
354
355
|
|
355
356
|
values.unshift(*first_value)
|
356
357
|
|
@@ -424,17 +425,17 @@ module ActionView
|
|
424
425
|
|
425
426
|
private
|
426
427
|
|
427
|
-
|
428
|
-
|
429
|
-
|
428
|
+
def next_index
|
429
|
+
step_index(1)
|
430
|
+
end
|
430
431
|
|
431
|
-
|
432
|
-
|
433
|
-
|
432
|
+
def previous_index
|
433
|
+
step_index(-1)
|
434
|
+
end
|
434
435
|
|
435
|
-
|
436
|
-
|
437
|
-
|
436
|
+
def step_index(n)
|
437
|
+
(@index + n) % @values.size
|
438
|
+
end
|
438
439
|
end
|
439
440
|
|
440
441
|
private
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "action_view/helpers/tag_helper"
|
2
|
+
require "active_support/core_ext/string/access"
|
3
|
+
require "i18n/exceptions"
|
4
4
|
|
5
5
|
module ActionView
|
6
6
|
# = Action View Translation Helpers
|
@@ -100,12 +100,12 @@ module ActionView
|
|
100
100
|
|
101
101
|
interpolations = options.except(:default, :scope)
|
102
102
|
if interpolations.any?
|
103
|
-
title << ", " << interpolations.map { |k, v| "#{k}: #{ERB::Util.html_escape(v)}" }.join(
|
103
|
+
title << ", " << interpolations.map { |k, v| "#{k}: #{ERB::Util.html_escape(v)}" }.join(", ")
|
104
104
|
end
|
105
105
|
|
106
106
|
return title unless ActionView::Base.debug_missing_translation
|
107
107
|
|
108
|
-
content_tag(
|
108
|
+
content_tag("span", keys.last.to_s.titleize, class: "translation_missing", title: title)
|
109
109
|
end
|
110
110
|
end
|
111
111
|
alias :t :translate
|
@@ -133,7 +133,7 @@ module ActionView
|
|
133
133
|
end
|
134
134
|
|
135
135
|
def html_safe_translation_key?(key)
|
136
|
-
|
136
|
+
/(\b|_|\.)html$/.match?(key.to_s)
|
137
137
|
end
|
138
138
|
end
|
139
139
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "action_view/helpers/javascript_helper"
|
2
|
+
require "active_support/core_ext/array/access"
|
3
|
+
require "active_support/core_ext/hash/keys"
|
4
|
+
require "active_support/core_ext/string/output_safety"
|
5
5
|
|
6
6
|
module ActionView
|
7
7
|
# = Action View URL Helpers
|
@@ -35,20 +35,20 @@ module ActionView
|
|
35
35
|
when :back
|
36
36
|
_back_url
|
37
37
|
else
|
38
|
-
raise ArgumentError, "arguments passed to url_for can't be handled. Please require "
|
38
|
+
raise ArgumentError, "arguments passed to url_for can't be handled. Please require " \
|
39
39
|
"routes or provide your own implementation"
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
def _back_url # :nodoc:
|
44
|
-
_filtered_referrer ||
|
44
|
+
_filtered_referrer || "javascript:history.back()"
|
45
45
|
end
|
46
46
|
protected :_back_url
|
47
47
|
|
48
48
|
def _filtered_referrer # :nodoc:
|
49
49
|
if controller.respond_to?(:request)
|
50
50
|
referrer = controller.request.env["HTTP_REFERER"]
|
51
|
-
if referrer && URI(referrer).scheme !=
|
51
|
+
if referrer && URI(referrer).scheme != "javascript"
|
52
52
|
referrer
|
53
53
|
end
|
54
54
|
end
|
@@ -105,10 +105,9 @@ module ActionView
|
|
105
105
|
# driver to prompt with the question specified (in this case, the
|
106
106
|
# resulting text would be <tt>question?</tt>. If the user accepts, the
|
107
107
|
# link is processed normally, otherwise no action is taken.
|
108
|
-
# * <tt>:disable_with</tt> - Value of this parameter will be
|
109
|
-
#
|
110
|
-
#
|
111
|
-
# by the unobtrusive JavaScript driver.
|
108
|
+
# * <tt>:disable_with</tt> - Value of this parameter will be used as the
|
109
|
+
# name for a disabled version of the link. This feature is provided by
|
110
|
+
# the unobtrusive JavaScript driver.
|
112
111
|
#
|
113
112
|
# ==== Examples
|
114
113
|
# Because it relies on +url_for+, +link_to+ supports both older-style controller/action/id arguments
|
@@ -298,34 +297,34 @@ module ActionView
|
|
298
297
|
html_options = html_options.stringify_keys
|
299
298
|
|
300
299
|
url = options.is_a?(String) ? options : url_for(options)
|
301
|
-
remote = html_options.delete(
|
302
|
-
params = html_options.delete(
|
300
|
+
remote = html_options.delete("remote")
|
301
|
+
params = html_options.delete("params")
|
303
302
|
|
304
|
-
method = html_options.delete(
|
305
|
-
method_tag = BUTTON_TAG_METHOD_VERBS.include?(method) ? method_tag(method) :
|
303
|
+
method = html_options.delete("method").to_s
|
304
|
+
method_tag = BUTTON_TAG_METHOD_VERBS.include?(method) ? method_tag(method) : "".freeze.html_safe
|
306
305
|
|
307
|
-
form_method = method ==
|
308
|
-
form_options = html_options.delete(
|
309
|
-
form_options[:class] ||= html_options.delete(
|
306
|
+
form_method = method == "get" ? "get" : "post"
|
307
|
+
form_options = html_options.delete("form") || {}
|
308
|
+
form_options[:class] ||= html_options.delete("form_class") || "button_to"
|
310
309
|
form_options[:method] = form_method
|
311
310
|
form_options[:action] = url
|
312
311
|
form_options[:'data-remote'] = true if remote
|
313
312
|
|
314
|
-
request_token_tag = if form_method ==
|
315
|
-
request_method = method.empty? ?
|
313
|
+
request_token_tag = if form_method == "post"
|
314
|
+
request_method = method.empty? ? "post" : method
|
316
315
|
token_tag(nil, form_options: { action: url, method: request_method })
|
317
316
|
else
|
318
|
-
|
317
|
+
"".freeze
|
319
318
|
end
|
320
319
|
|
321
320
|
html_options = convert_options_to_data_attributes(options, html_options)
|
322
|
-
html_options[
|
321
|
+
html_options["type"] = "submit"
|
323
322
|
|
324
323
|
button = if block_given?
|
325
|
-
content_tag(
|
324
|
+
content_tag("button", html_options, &block)
|
326
325
|
else
|
327
|
-
html_options[
|
328
|
-
tag(
|
326
|
+
html_options["value"] = name || url
|
327
|
+
tag("input", html_options)
|
329
328
|
end
|
330
329
|
|
331
330
|
inner_tags = method_tag.safe_concat(button).safe_concat(request_token_tag)
|
@@ -334,7 +333,7 @@ module ActionView
|
|
334
333
|
inner_tags.safe_concat tag(:input, type: "hidden", name: param[:name], value: param[:value])
|
335
334
|
end
|
336
335
|
end
|
337
|
-
content_tag(
|
336
|
+
content_tag("form", inner_tags, form_options)
|
338
337
|
end
|
339
338
|
|
340
339
|
# Creates a link tag of the given +name+ using a URL created by the set of
|
@@ -481,7 +480,7 @@ module ActionView
|
|
481
480
|
option = html_options.delete(item).presence || next
|
482
481
|
"#{item.dasherize}=#{ERB::Util.url_encode(option)}"
|
483
482
|
}.compact
|
484
|
-
extras = extras.empty? ?
|
483
|
+
extras = extras.empty? ? "".freeze : "?" + extras.join("&")
|
485
484
|
|
486
485
|
encoded_email_address = ERB::Util.url_encode(email_address).gsub("%40", "@")
|
487
486
|
html_options["href"] = "mailto:#{encoded_email_address}#{extras}"
|
@@ -518,6 +517,9 @@ module ActionView
|
|
518
517
|
# current_page?('http://www.example.com/shop/checkout')
|
519
518
|
# # => true
|
520
519
|
#
|
520
|
+
# current_page?('http://www.example.com/shop/checkout', check_parameters: true)
|
521
|
+
# # => false
|
522
|
+
#
|
521
523
|
# current_page?('/shop/checkout')
|
522
524
|
# # => true
|
523
525
|
#
|
@@ -531,7 +533,7 @@ module ActionView
|
|
531
533
|
#
|
532
534
|
# We can also pass in the symbol arguments instead of strings.
|
533
535
|
#
|
534
|
-
def current_page?(options)
|
536
|
+
def current_page?(options, check_parameters: false)
|
535
537
|
unless request
|
536
538
|
raise "You cannot use helpers that need to determine the current " \
|
537
539
|
"page unless your view context provides a Request object " \
|
@@ -540,17 +542,19 @@ module ActionView
|
|
540
542
|
|
541
543
|
return false unless request.get? || request.head?
|
542
544
|
|
545
|
+
check_parameters ||= !options.is_a?(String) && options.try(:delete, :check_parameters)
|
543
546
|
url_string = URI.parser.unescape(url_for(options)).force_encoding(Encoding::BINARY)
|
544
547
|
|
545
548
|
# We ignore any extra parameters in the request_uri if the
|
546
549
|
# submitted url doesn't have any either. This lets the function
|
547
550
|
# work with things like ?order=asc
|
548
|
-
|
551
|
+
# the behaviour can be disabled with check_parameters: true
|
552
|
+
request_uri = url_string.index("?") || check_parameters ? request.fullpath : request.path
|
549
553
|
request_uri = URI.parser.unescape(request_uri).force_encoding(Encoding::BINARY)
|
550
554
|
|
551
555
|
url_string.chomp!("/") if url_string.start_with?("/") && url_string != "/"
|
552
556
|
|
553
|
-
if url_string
|
557
|
+
if %r{^\w+://}.match?(url_string)
|
554
558
|
url_string == "#{request.protocol}#{request.host_with_port}#{request_uri}"
|
555
559
|
else
|
556
560
|
url_string == request_uri
|
@@ -561,21 +565,21 @@ module ActionView
|
|
561
565
|
def convert_options_to_data_attributes(options, html_options)
|
562
566
|
if html_options
|
563
567
|
html_options = html_options.stringify_keys
|
564
|
-
html_options[
|
568
|
+
html_options["data-remote"] = "true".freeze if link_to_remote_options?(options) || link_to_remote_options?(html_options)
|
565
569
|
|
566
|
-
method
|
570
|
+
method = html_options.delete("method".freeze)
|
567
571
|
|
568
572
|
add_method_to_attributes!(html_options, method) if method
|
569
573
|
|
570
574
|
html_options
|
571
575
|
else
|
572
|
-
link_to_remote_options?(options) ? {
|
576
|
+
link_to_remote_options?(options) ? { "data-remote" => "true".freeze } : {}
|
573
577
|
end
|
574
578
|
end
|
575
579
|
|
576
580
|
def link_to_remote_options?(options)
|
577
581
|
if options.is_a?(Hash)
|
578
|
-
options.delete(
|
582
|
+
options.delete("remote".freeze) || options.delete(:remote)
|
579
583
|
end
|
580
584
|
end
|
581
585
|
|
@@ -586,17 +590,17 @@ module ActionView
|
|
586
590
|
html_options["data-method".freeze] = method
|
587
591
|
end
|
588
592
|
|
589
|
-
def token_tag(token=nil, form_options: {})
|
593
|
+
def token_tag(token = nil, form_options: {})
|
590
594
|
if token != false && protect_against_forgery?
|
591
595
|
token ||= form_authenticity_token(form_options: form_options)
|
592
596
|
tag(:input, type: "hidden", name: request_forgery_protection_token.to_s, value: token)
|
593
597
|
else
|
594
|
-
|
598
|
+
"".freeze
|
595
599
|
end
|
596
600
|
end
|
597
601
|
|
598
602
|
def method_tag(method)
|
599
|
-
tag(
|
603
|
+
tag("input", type: "hidden", name: "_method", value: method.to_s)
|
600
604
|
end
|
601
605
|
|
602
606
|
# Returns an array of hashes each containing :name and :value keys
|
@@ -615,7 +619,7 @@ module ActionView
|
|
615
619
|
#
|
616
620
|
# to_form_params({ name: 'Denmark' }, 'country')
|
617
621
|
# # => [{name: 'country[name]', value: 'Denmark'}]
|
618
|
-
def to_form_params(attribute, namespace = nil)
|
622
|
+
def to_form_params(attribute, namespace = nil)
|
619
623
|
attribute = if attribute.respond_to?(:permitted?)
|
620
624
|
unless attribute.permitted?
|
621
625
|
raise ArgumentError, "Attempting to generate a buttom from non-sanitized request parameters!" \
|