actionview 5.1.7 → 5.2.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 +27 -275
- data/README.rdoc +1 -1
- data/lib/action_view.rb +3 -2
- data/lib/action_view/base.rb +8 -10
- data/lib/action_view/buffers.rb +2 -0
- data/lib/action_view/context.rb +2 -2
- data/lib/action_view/dependency_tracker.rb +2 -0
- data/lib/action_view/digestor.rb +6 -12
- data/lib/action_view/flows.rb +2 -0
- data/lib/action_view/gem_version.rb +5 -3
- data/lib/action_view/helpers.rb +2 -0
- data/lib/action_view/helpers/active_model_helper.rb +9 -3
- data/lib/action_view/helpers/asset_tag_helper.rb +79 -22
- data/lib/action_view/helpers/asset_url_helper.rb +13 -11
- data/lib/action_view/helpers/atom_feed_helper.rb +3 -1
- data/lib/action_view/helpers/cache_helper.rb +24 -14
- data/lib/action_view/helpers/capture_helper.rb +9 -7
- data/lib/action_view/helpers/controller_helper.rb +3 -1
- data/lib/action_view/helpers/csrf_helper.rb +4 -2
- data/lib/action_view/helpers/date_helper.rb +5 -3
- data/lib/action_view/helpers/debug_helper.rb +3 -1
- data/lib/action_view/helpers/form_helper.rb +43 -60
- data/lib/action_view/helpers/form_options_helper.rb +9 -7
- data/lib/action_view/helpers/form_tag_helper.rb +20 -11
- data/lib/action_view/helpers/javascript_helper.rb +5 -3
- data/lib/action_view/helpers/number_helper.rb +2 -0
- data/lib/action_view/helpers/output_safety_helper.rb +2 -0
- data/lib/action_view/helpers/record_tag_helper.rb +3 -1
- data/lib/action_view/helpers/rendering_helper.rb +4 -1
- data/lib/action_view/helpers/sanitize_helper.rb +3 -1
- data/lib/action_view/helpers/tag_helper.rb +2 -2
- data/lib/action_view/helpers/tags.rb +3 -1
- data/lib/action_view/helpers/tags/base.rb +12 -10
- data/lib/action_view/helpers/tags/check_box.rb +3 -1
- data/lib/action_view/helpers/tags/checkable.rb +4 -2
- data/lib/action_view/helpers/tags/collection_check_boxes.rb +2 -0
- data/lib/action_view/helpers/tags/collection_helpers.rb +2 -0
- data/lib/action_view/helpers/tags/collection_radio_buttons.rb +2 -0
- data/lib/action_view/helpers/tags/collection_select.rb +3 -1
- data/lib/action_view/helpers/tags/color_field.rb +3 -1
- data/lib/action_view/helpers/tags/date_field.rb +2 -0
- data/lib/action_view/helpers/tags/date_select.rb +3 -1
- data/lib/action_view/helpers/tags/datetime_field.rb +3 -1
- data/lib/action_view/helpers/tags/datetime_local_field.rb +2 -0
- data/lib/action_view/helpers/tags/datetime_select.rb +2 -0
- data/lib/action_view/helpers/tags/email_field.rb +2 -0
- data/lib/action_view/helpers/tags/file_field.rb +2 -0
- data/lib/action_view/helpers/tags/grouped_collection_select.rb +3 -1
- data/lib/action_view/helpers/tags/hidden_field.rb +2 -0
- data/lib/action_view/helpers/tags/label.rb +2 -4
- data/lib/action_view/helpers/tags/month_field.rb +2 -0
- data/lib/action_view/helpers/tags/number_field.rb +2 -0
- data/lib/action_view/helpers/tags/password_field.rb +2 -0
- data/lib/action_view/helpers/tags/placeholderable.rb +2 -0
- data/lib/action_view/helpers/tags/radio_button.rb +3 -1
- data/lib/action_view/helpers/tags/range_field.rb +2 -0
- data/lib/action_view/helpers/tags/search_field.rb +2 -0
- data/lib/action_view/helpers/tags/select.rb +5 -3
- data/lib/action_view/helpers/tags/tel_field.rb +2 -0
- data/lib/action_view/helpers/tags/text_area.rb +3 -1
- data/lib/action_view/helpers/tags/text_field.rb +3 -1
- data/lib/action_view/helpers/tags/time_field.rb +2 -0
- data/lib/action_view/helpers/tags/time_select.rb +2 -0
- data/lib/action_view/helpers/tags/time_zone_select.rb +3 -1
- data/lib/action_view/helpers/tags/translator.rb +2 -0
- data/lib/action_view/helpers/tags/url_field.rb +2 -0
- data/lib/action_view/helpers/tags/week_field.rb +2 -0
- data/lib/action_view/helpers/text_helper.rb +4 -2
- data/lib/action_view/helpers/translation_helper.rb +5 -4
- data/lib/action_view/helpers/url_helper.rb +24 -5
- data/lib/action_view/layouts.rb +7 -5
- data/lib/action_view/log_subscriber.rb +5 -3
- data/lib/action_view/lookup_context.rb +4 -4
- data/lib/action_view/model_naming.rb +2 -0
- data/lib/action_view/path_set.rb +2 -0
- data/lib/action_view/railtie.rb +11 -2
- data/lib/action_view/record_identifier.rb +2 -0
- data/lib/action_view/renderer/abstract_renderer.rb +2 -0
- data/lib/action_view/renderer/partial_renderer.rb +13 -11
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +4 -2
- data/lib/action_view/renderer/renderer.rb +2 -0
- data/lib/action_view/renderer/streaming_template_renderer.rb +3 -1
- data/lib/action_view/renderer/template_renderer.rb +2 -0
- data/lib/action_view/rendering.rb +3 -5
- data/lib/action_view/routing_url_for.rb +2 -0
- data/lib/action_view/tasks/cache_digests.rake +2 -0
- data/lib/action_view/template.rb +6 -4
- data/lib/action_view/template/error.rb +2 -3
- data/lib/action_view/template/handlers.rb +3 -1
- data/lib/action_view/template/handlers/builder.rb +3 -4
- data/lib/action_view/template/handlers/erb.rb +5 -9
- data/lib/action_view/template/handlers/erb/erubi.rb +2 -0
- data/lib/action_view/template/handlers/html.rb +2 -0
- data/lib/action_view/template/handlers/raw.rb +2 -0
- data/lib/action_view/template/html.rb +3 -1
- data/lib/action_view/template/resolver.rb +7 -6
- data/lib/action_view/template/text.rb +3 -1
- data/lib/action_view/template/types.rb +3 -1
- data/lib/action_view/test_case.rb +21 -5
- data/lib/action_view/testing/resolvers.rb +3 -1
- data/lib/action_view/version.rb +2 -0
- data/lib/action_view/view_paths.rb +3 -3
- data/lib/assets/compiled/rails-ujs.js +3 -3
- metadata +14 -15
- data/lib/action_view/template/handlers/erb/deprecated_erubis.rb +0 -9
- data/lib/action_view/template/handlers/erb/erubis.rb +0 -81
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "action_view/helpers/tag_helper"
|
2
4
|
|
3
5
|
module ActionView
|
4
|
-
module Helpers
|
6
|
+
module Helpers #:nodoc:
|
5
7
|
module JavaScriptHelper
|
6
8
|
JS_ESCAPE_MAP = {
|
7
9
|
'\\' => '\\\\',
|
@@ -13,8 +15,8 @@ module ActionView
|
|
13
15
|
"'" => "\\'"
|
14
16
|
}
|
15
17
|
|
16
|
-
JS_ESCAPE_MAP["\342\200\250".force_encoding(Encoding::UTF_8).encode!] = "
"
|
17
|
-
JS_ESCAPE_MAP["\342\200\251".force_encoding(Encoding::UTF_8).encode!] = "
"
|
18
|
+
JS_ESCAPE_MAP["\342\200\250".dup.force_encoding(Encoding::UTF_8).encode!] = "
"
|
19
|
+
JS_ESCAPE_MAP["\342\200\251".dup.force_encoding(Encoding::UTF_8).encode!] = "
"
|
18
20
|
|
19
21
|
# Escapes carriage returns and single and double quotes for JavaScript segments.
|
20
22
|
#
|
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
|
-
module Helpers
|
4
|
+
module Helpers #:nodoc:
|
3
5
|
# = Action View Rendering
|
4
6
|
#
|
5
7
|
# Implements methods that allow rendering from a view context.
|
@@ -11,6 +13,7 @@ module ActionView
|
|
11
13
|
# * <tt>:partial</tt> - See <tt>ActionView::PartialRenderer</tt>.
|
12
14
|
# * <tt>:file</tt> - Renders an explicit template file (this used to be the old default), add :locals to pass in those.
|
13
15
|
# * <tt>:inline</tt> - Renders an inline template similar to how it's done in the controller.
|
16
|
+
# * <tt>:text</tt> - Renders the text passed in out.
|
14
17
|
# * <tt>:plain</tt> - Renders the text passed in out. Setting the content
|
15
18
|
# type as <tt>text/plain</tt>.
|
16
19
|
# * <tt>:html</tt> - Renders the HTML safe string passed in out, otherwise
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "active_support/core_ext/object/try"
|
2
4
|
require "rails-html-sanitizer"
|
3
5
|
|
4
6
|
module ActionView
|
5
7
|
# = Action View Sanitize Helpers
|
6
|
-
module Helpers
|
8
|
+
module Helpers #:nodoc:
|
7
9
|
# The SanitizeHelper module provides a set of methods for scrubbing text of undesired HTML elements.
|
8
10
|
# These helper methods extend Action View making them callable within your template files.
|
9
11
|
module SanitizeHelper
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "active_support/core_ext/string/output_safety"
|
4
4
|
require "set"
|
@@ -166,7 +166,7 @@ module ActionView
|
|
166
166
|
# This may come in handy when using jQuery's HTML5-aware <tt>.data()</tt>
|
167
167
|
# from 1.4.3.
|
168
168
|
#
|
169
|
-
# tag.div data: { city_state: %w(
|
169
|
+
# tag.div data: { city_state: %w( Chicago IL ) }
|
170
170
|
# # => <div data-city-state="["Chicago","IL"]"></div>
|
171
171
|
#
|
172
172
|
# The generated attributes are escaped by default. This can be disabled using
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
@@ -33,7 +35,7 @@ module ActionView
|
|
33
35
|
|
34
36
|
private
|
35
37
|
|
36
|
-
def value
|
38
|
+
def value
|
37
39
|
if @allow_method_names_outside_object
|
38
40
|
object.public_send @method_name if object && object.respond_to?(@method_name)
|
39
41
|
else
|
@@ -41,19 +43,19 @@ module ActionView
|
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
|
-
def value_before_type_cast
|
46
|
+
def value_before_type_cast
|
45
47
|
unless object.nil?
|
46
48
|
method_before_type_cast = @method_name + "_before_type_cast"
|
47
49
|
|
48
|
-
if value_came_from_user?
|
50
|
+
if value_came_from_user? && object.respond_to?(method_before_type_cast)
|
49
51
|
object.public_send(method_before_type_cast)
|
50
52
|
else
|
51
|
-
value
|
53
|
+
value
|
52
54
|
end
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
56
|
-
def value_came_from_user?
|
58
|
+
def value_came_from_user?
|
57
59
|
method_name = "#{@method_name}_came_from_user?"
|
58
60
|
!object.respond_to?(method_name) || object.public_send(method_name)
|
59
61
|
end
|
@@ -95,7 +97,7 @@ module ActionView
|
|
95
97
|
index = name_and_id_index(options)
|
96
98
|
options["name"] = options.fetch("name") { tag_name(options["multiple"], index) }
|
97
99
|
|
98
|
-
|
100
|
+
if generate_ids?
|
99
101
|
options["id"] = options.fetch("id") { tag_id(index) }
|
100
102
|
if namespace = options.delete("namespace")
|
101
103
|
options["id"] = options["id"] ? "#{namespace}_#{options['id']}" : namespace
|
@@ -148,8 +150,8 @@ module ActionView
|
|
148
150
|
options[:include_blank] ||= true unless options[:prompt]
|
149
151
|
end
|
150
152
|
|
151
|
-
value = options.fetch(:selected) { value(
|
152
|
-
select = content_tag("select", add_options(option_tags, options, value), html_options
|
153
|
+
value = options.fetch(:selected) { value() }
|
154
|
+
select = content_tag("select", add_options(option_tags, options, value), html_options)
|
153
155
|
|
154
156
|
if html_options["multiple"] && options.fetch(:include_hidden, true)
|
155
157
|
tag("input", disabled: html_options["disabled"], name: html_options["name"], type: "hidden", value: "") + select
|
@@ -181,8 +183,8 @@ module ActionView
|
|
181
183
|
end
|
182
184
|
end
|
183
185
|
|
184
|
-
def
|
185
|
-
|
186
|
+
def generate_ids?
|
187
|
+
!@skip_default_ids
|
186
188
|
end
|
187
189
|
end
|
188
190
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "action_view/helpers/tags/checkable"
|
2
4
|
|
3
5
|
module ActionView
|
@@ -16,7 +18,7 @@ module ActionView
|
|
16
18
|
options = @options.stringify_keys
|
17
19
|
options["type"] = "checkbox"
|
18
20
|
options["value"] = @checked_value
|
19
|
-
options["checked"] = "checked" if input_checked?(
|
21
|
+
options["checked"] = "checked" if input_checked?(options)
|
20
22
|
|
21
23
|
if options["multiple"]
|
22
24
|
add_default_name_and_id_for_value(@checked_value, options)
|
@@ -1,13 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
4
6
|
module Checkable # :nodoc:
|
5
|
-
def input_checked?(
|
7
|
+
def input_checked?(options)
|
6
8
|
if options.has_key?("checked")
|
7
9
|
checked = options.delete "checked"
|
8
10
|
checked == true || checked == "checked"
|
9
11
|
else
|
10
|
-
checked?(value
|
12
|
+
checked?(value)
|
11
13
|
end
|
12
14
|
end
|
13
15
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
@@ -13,7 +15,7 @@ module ActionView
|
|
13
15
|
|
14
16
|
def render
|
15
17
|
option_tags_options = {
|
16
|
-
selected: @options.fetch(:selected) { value
|
18
|
+
selected: @options.fetch(:selected) { value },
|
17
19
|
disabled: @options[:disabled]
|
18
20
|
}
|
19
21
|
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
4
6
|
class ColorField < TextField # :nodoc:
|
5
7
|
def render
|
6
8
|
options = @options.stringify_keys
|
7
|
-
options["value"] ||= validate_color_string(value
|
9
|
+
options["value"] ||= validate_color_string(value)
|
8
10
|
@options = options
|
9
11
|
super
|
10
12
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "active_support/core_ext/time/calculations"
|
2
4
|
|
3
5
|
module ActionView
|
@@ -27,7 +29,7 @@ module ActionView
|
|
27
29
|
end
|
28
30
|
|
29
31
|
def datetime_selector(options, html_options)
|
30
|
-
datetime = options.fetch(:selected) { value
|
32
|
+
datetime = options.fetch(:selected) { value || default_datetime(options) }
|
31
33
|
@auto_index ||= nil
|
32
34
|
|
33
35
|
options = options.dup
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
4
6
|
class DatetimeField < TextField # :nodoc:
|
5
7
|
def render
|
6
8
|
options = @options.stringify_keys
|
7
|
-
options["value"] ||= format_date(value
|
9
|
+
options["value"] ||= format_date(value)
|
8
10
|
options["min"] = format_date(datetime_value(options["min"]))
|
9
11
|
options["max"] = format_date(datetime_value(options["max"]))
|
10
12
|
@options = options
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
@@ -15,7 +17,7 @@ module ActionView
|
|
15
17
|
|
16
18
|
def render
|
17
19
|
option_tags_options = {
|
18
|
-
selected: @options.fetch(:selected) { value
|
20
|
+
selected: @options.fetch(:selected) { value },
|
19
21
|
disabled: @options[:disabled]
|
20
22
|
}
|
21
23
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
@@ -73,10 +75,6 @@ module ActionView
|
|
73
75
|
def render_component(builder)
|
74
76
|
builder.translation
|
75
77
|
end
|
76
|
-
|
77
|
-
def skip_default_ids?
|
78
|
-
false # The id is used as the `for` attribute.
|
79
|
-
end
|
80
78
|
end
|
81
79
|
end
|
82
80
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "action_view/helpers/tags/checkable"
|
2
4
|
|
3
5
|
module ActionView
|
@@ -15,7 +17,7 @@ module ActionView
|
|
15
17
|
options = @options.stringify_keys
|
16
18
|
options["type"] = "radio"
|
17
19
|
options["value"] = @tag_value
|
18
|
-
options["checked"] = "checked" if input_checked?(
|
20
|
+
options["checked"] = "checked" if input_checked?(options)
|
19
21
|
add_default_name_and_id_for_value(@tag_value, options)
|
20
22
|
tag("input", options)
|
21
23
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
@@ -6,14 +8,14 @@ module ActionView
|
|
6
8
|
@choices = block_given? ? template_object.capture { yield || "" } : choices
|
7
9
|
@choices = @choices.to_a if @choices.is_a?(Range)
|
8
10
|
|
9
|
-
@html_options = html_options
|
11
|
+
@html_options = html_options.except(:skip_default_ids, :allow_method_names_outside_object)
|
10
12
|
|
11
13
|
super(object_name, method_name, template_object, options)
|
12
14
|
end
|
13
15
|
|
14
16
|
def render
|
15
17
|
option_tags_options = {
|
16
|
-
selected: @options.fetch(:selected) { value
|
18
|
+
selected: @options.fetch(:selected) { value },
|
17
19
|
disabled: @options[:disabled]
|
18
20
|
}
|
19
21
|
|
@@ -33,7 +35,7 @@ module ActionView
|
|
33
35
|
# [nil, []]
|
34
36
|
# { nil => [] }
|
35
37
|
def grouped_choices?
|
36
|
-
!@choices.
|
38
|
+
!@choices.blank? && @choices.first.respond_to?(:last) && Array === @choices.first.last
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|