actionview 7.2.2.1 → 8.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +104 -71
- data/README.rdoc +1 -1
- data/lib/action_view/base.rb +11 -11
- data/lib/action_view/buffers.rb +1 -1
- data/lib/action_view/dependency_tracker/erb_tracker.rb +37 -28
- data/lib/action_view/dependency_tracker/ruby_tracker.rb +2 -19
- data/lib/action_view/dependency_tracker/wildcard_resolver.rb +32 -0
- data/lib/action_view/dependency_tracker.rb +7 -1
- data/lib/action_view/digestor.rb +6 -2
- data/lib/action_view/gem_version.rb +3 -3
- data/lib/action_view/helpers/asset_tag_helper.rb +25 -6
- data/lib/action_view/helpers/atom_feed_helper.rb +1 -3
- data/lib/action_view/helpers/cache_helper.rb +10 -2
- data/lib/action_view/helpers/capture_helper.rb +2 -2
- data/lib/action_view/helpers/controller_helper.rb +6 -2
- data/lib/action_view/helpers/date_helper.rb +28 -4
- data/lib/action_view/helpers/form_helper.rb +103 -103
- data/lib/action_view/helpers/form_options_helper.rb +39 -35
- data/lib/action_view/helpers/form_tag_helper.rb +35 -25
- data/lib/action_view/helpers/javascript_helper.rb +5 -1
- data/lib/action_view/helpers/number_helper.rb +14 -0
- data/lib/action_view/helpers/output_safety_helper.rb +1 -2
- data/lib/action_view/helpers/rendering_helper.rb +160 -50
- data/lib/action_view/helpers/sanitize_helper.rb +6 -0
- data/lib/action_view/helpers/tag_helper.rb +57 -73
- data/lib/action_view/helpers/tags/base.rb +11 -9
- data/lib/action_view/helpers/tags/check_box.rb +9 -3
- data/lib/action_view/helpers/tags/collection_check_boxes.rb +4 -3
- data/lib/action_view/helpers/tags/collection_helpers.rb +2 -1
- data/lib/action_view/helpers/tags/datetime_field.rb +1 -1
- data/lib/action_view/helpers/tags/file_field.rb +7 -2
- data/lib/action_view/helpers/tags/hidden_field.rb +1 -1
- data/lib/action_view/helpers/tags/label.rb +3 -10
- data/lib/action_view/helpers/tags/radio_button.rb +1 -1
- data/lib/action_view/helpers/tags/select.rb +6 -1
- data/lib/action_view/helpers/tags/select_renderer.rb +6 -4
- data/lib/action_view/helpers/tags/text_area.rb +1 -1
- data/lib/action_view/helpers/tags/text_field.rb +1 -1
- data/lib/action_view/helpers/text_helper.rb +10 -3
- data/lib/action_view/helpers/translation_helper.rb +6 -1
- data/lib/action_view/helpers/url_helper.rb +39 -13
- data/lib/action_view/layouts.rb +7 -7
- data/lib/action_view/locale/en.yml +3 -0
- data/lib/action_view/log_subscriber.rb +1 -4
- data/lib/action_view/railtie.rb +12 -1
- data/lib/action_view/record_identifier.rb +22 -1
- data/lib/action_view/render_parser/prism_render_parser.rb +13 -1
- data/lib/action_view/render_parser/ripper_render_parser.rb +10 -1
- data/lib/action_view/renderer/partial_renderer.rb +18 -2
- data/lib/action_view/renderer/streaming_template_renderer.rb +8 -2
- data/lib/action_view/renderer/template_renderer.rb +3 -3
- data/lib/action_view/rendering.rb +2 -3
- data/lib/action_view/structured_event_subscriber.rb +97 -0
- data/lib/action_view/template/error.rb +18 -3
- data/lib/action_view/template/handlers/erb/erubi.rb +1 -1
- data/lib/action_view/template/handlers/erb.rb +77 -44
- data/lib/action_view/template/raw_file.rb +4 -0
- data/lib/action_view/template/resolver.rb +0 -1
- data/lib/action_view/template.rb +3 -4
- data/lib/action_view/test_case.rb +50 -53
- data/lib/action_view.rb +4 -0
- metadata +15 -16
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "set"
|
|
4
|
-
|
|
5
3
|
module ActionView
|
|
6
4
|
module Helpers # :nodoc:
|
|
7
5
|
# = Action View Atom Feed \Helpers
|
|
@@ -172,7 +170,7 @@ module ActionView
|
|
|
172
170
|
|
|
173
171
|
# Creates an entry tag for a specific record and prefills the id using class and id.
|
|
174
172
|
#
|
|
175
|
-
# Options
|
|
173
|
+
# ==== Options
|
|
176
174
|
#
|
|
177
175
|
# * <tt>:published</tt>: Time first published. Defaults to the created_at attribute on the record if one such exists.
|
|
178
176
|
# * <tt>:updated</tt>: Time of update. Defaults to the updated_at attribute on the record if one such exists.
|
|
@@ -93,6 +93,14 @@ module ActionView
|
|
|
93
93
|
# render partial: 'attachments/attachment', collection: group_of_attachments
|
|
94
94
|
# render partial: 'documents/document', collection: @project.documents.where(published: true).order('created_at')
|
|
95
95
|
#
|
|
96
|
+
# One last type of dependency can be determined implicitly:
|
|
97
|
+
#
|
|
98
|
+
# render "maintenance_tasks/runs/info/#{run.status}"
|
|
99
|
+
#
|
|
100
|
+
# Because the value passed to render ends in interpolation, Action View
|
|
101
|
+
# will mark all partials within the "maintenance_tasks/runs/info" folder as
|
|
102
|
+
# dependencies.
|
|
103
|
+
#
|
|
96
104
|
# === Explicit dependencies
|
|
97
105
|
#
|
|
98
106
|
# Sometimes you'll have template dependencies that can't be derived at all. This is typically
|
|
@@ -189,7 +197,7 @@ module ActionView
|
|
|
189
197
|
CachingRegistry.caching?
|
|
190
198
|
end
|
|
191
199
|
|
|
192
|
-
# Raises
|
|
200
|
+
# Raises UncacheableFragmentError when called from within a +cache+ block.
|
|
193
201
|
#
|
|
194
202
|
# Useful to denote helper methods that can't participate in fragment caching:
|
|
195
203
|
#
|
|
@@ -198,7 +206,7 @@ module ActionView
|
|
|
198
206
|
# "#{project.name} - #{Time.now}"
|
|
199
207
|
# end
|
|
200
208
|
#
|
|
201
|
-
# # Which will then raise if used within a
|
|
209
|
+
# # Which will then raise if used within a `cache` block:
|
|
202
210
|
# <% cache project do %>
|
|
203
211
|
# <%= project_name_with_time(project) %>
|
|
204
212
|
# <% end %>
|
|
@@ -44,10 +44,10 @@ module ActionView
|
|
|
44
44
|
#
|
|
45
45
|
# @greeting # => "Welcome to my shiny new web page! The date and time is 2018-09-06 11:09:16 -0500"
|
|
46
46
|
#
|
|
47
|
-
def capture(
|
|
47
|
+
def capture(*, **, &block)
|
|
48
48
|
value = nil
|
|
49
49
|
@output_buffer ||= ActionView::OutputBuffer.new
|
|
50
|
-
buffer = @output_buffer.capture { value = yield(
|
|
50
|
+
buffer = @output_buffer.capture { value = yield(*, **) }
|
|
51
51
|
|
|
52
52
|
string = if @output_buffer.equal?(value)
|
|
53
53
|
buffer
|
|
@@ -20,11 +20,15 @@ module ActionView
|
|
|
20
20
|
def assign_controller(controller)
|
|
21
21
|
if @_controller = controller
|
|
22
22
|
@_request = controller.request if controller.respond_to?(:request)
|
|
23
|
-
|
|
23
|
+
if controller.respond_to?(:config)
|
|
24
|
+
@_config = controller.config.inheritable_copy
|
|
25
|
+
else
|
|
26
|
+
@_config = ActiveSupport::InheritableOptions.new
|
|
27
|
+
end
|
|
24
28
|
@_default_form_builder = controller.default_form_builder if controller.respond_to?(:default_form_builder)
|
|
25
29
|
else
|
|
26
30
|
@_request ||= nil
|
|
27
|
-
@_config
|
|
31
|
+
@_config = ActiveSupport::InheritableOptions.new
|
|
28
32
|
@_default_form_builder ||= nil
|
|
29
33
|
end
|
|
30
34
|
end
|
|
@@ -136,8 +136,15 @@ module ActionView
|
|
|
136
136
|
from_year += 1 if from_time.month >= 3
|
|
137
137
|
to_year = to_time.year
|
|
138
138
|
to_year -= 1 if to_time.month < 3
|
|
139
|
-
|
|
139
|
+
|
|
140
|
+
leap_years = if from_year > to_year
|
|
141
|
+
0
|
|
142
|
+
else
|
|
143
|
+
fyear = from_year - 1
|
|
144
|
+
(to_year / 4 - to_year / 100 + to_year / 400) - (fyear / 4 - fyear / 100 + fyear / 400)
|
|
145
|
+
end
|
|
140
146
|
minute_offset_for_leap_year = leap_years * 1440
|
|
147
|
+
|
|
141
148
|
# Discount the leap year days when calculating year distance.
|
|
142
149
|
# e.g. if there are 20 leap year days between 2 dates having the same day
|
|
143
150
|
# and month then based on 365 days calculation
|
|
@@ -179,6 +186,23 @@ module ActionView
|
|
|
179
186
|
|
|
180
187
|
alias_method :distance_of_time_in_words_to_now, :time_ago_in_words
|
|
181
188
|
|
|
189
|
+
# Like <tt>time_ago_in_words</tt>, but adds a prefix/suffix depending on whether the time is in the past or future.
|
|
190
|
+
# You can use the <tt>scope</tt> option to customize the translation scope. All other options
|
|
191
|
+
# are forwarded to <tt>time_ago_in_words</tt>.
|
|
192
|
+
#
|
|
193
|
+
# relative_time_in_words(3.minutes.from_now) # => "in 3 minutes"
|
|
194
|
+
# relative_time_in_words(3.minutes.ago) # => "3 minutes ago"
|
|
195
|
+
# relative_time_in_words(10.seconds.ago, include_seconds: true) # => "less than 10 seconds ago"
|
|
196
|
+
#
|
|
197
|
+
# See also #time_ago_in_words
|
|
198
|
+
def relative_time_in_words(from_time, options = {})
|
|
199
|
+
now = Time.now
|
|
200
|
+
time = distance_of_time_in_words(from_time, now, options.except(:scope))
|
|
201
|
+
key = from_time > now ? :future : :past
|
|
202
|
+
|
|
203
|
+
I18n.t(key, time: time, scope: options.fetch(:scope, :'datetime.relative'), locale: options[:locale])
|
|
204
|
+
end
|
|
205
|
+
|
|
182
206
|
# Returns a set of select tags (one for year, month, and day) pre-selected for accessing a specified date-based
|
|
183
207
|
# attribute (identified by +method+) on an object assigned to the template (identified by +object+).
|
|
184
208
|
#
|
|
@@ -1228,7 +1252,7 @@ module ActionView
|
|
|
1228
1252
|
class FormBuilder
|
|
1229
1253
|
# Wraps ActionView::Helpers::DateHelper#date_select for form builders:
|
|
1230
1254
|
#
|
|
1231
|
-
# <%=
|
|
1255
|
+
# <%= form_with model: @person do |f| %>
|
|
1232
1256
|
# <%= f.date_select :birth_date %>
|
|
1233
1257
|
# <%= f.submit %>
|
|
1234
1258
|
# <% end %>
|
|
@@ -1240,7 +1264,7 @@ module ActionView
|
|
|
1240
1264
|
|
|
1241
1265
|
# Wraps ActionView::Helpers::DateHelper#time_select for form builders:
|
|
1242
1266
|
#
|
|
1243
|
-
# <%=
|
|
1267
|
+
# <%= form_with model: @race do |f| %>
|
|
1244
1268
|
# <%= f.time_select :average_lap %>
|
|
1245
1269
|
# <%= f.submit %>
|
|
1246
1270
|
# <% end %>
|
|
@@ -1252,7 +1276,7 @@ module ActionView
|
|
|
1252
1276
|
|
|
1253
1277
|
# Wraps ActionView::Helpers::DateHelper#datetime_select for form builders:
|
|
1254
1278
|
#
|
|
1255
|
-
# <%=
|
|
1279
|
+
# <%= form_with model: @person do |f| %>
|
|
1256
1280
|
# <%= f.datetime_select :last_request_at %>
|
|
1257
1281
|
# <%= f.submit %>
|
|
1258
1282
|
# <% end %>
|