actionview 6.0.0.beta1 → 6.1.4

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.

Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +273 -119
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +5 -3
  5. data/lib/action_view/base.rb +81 -15
  6. data/lib/action_view/cache_expiry.rb +52 -0
  7. data/lib/action_view/context.rb +0 -5
  8. data/lib/action_view/dependency_tracker.rb +10 -4
  9. data/lib/action_view/digestor.rb +11 -19
  10. data/lib/action_view/flows.rb +0 -1
  11. data/lib/action_view/gem_version.rb +3 -3
  12. data/lib/action_view/helpers/active_model_helper.rb +0 -1
  13. data/lib/action_view/helpers/asset_tag_helper.rb +62 -22
  14. data/lib/action_view/helpers/asset_url_helper.rb +6 -4
  15. data/lib/action_view/helpers/atom_feed_helper.rb +2 -1
  16. data/lib/action_view/helpers/cache_helper.rb +16 -23
  17. data/lib/action_view/helpers/csp_helper.rb +4 -2
  18. data/lib/action_view/helpers/date_helper.rb +5 -6
  19. data/lib/action_view/helpers/form_helper.rb +70 -34
  20. data/lib/action_view/helpers/form_options_helper.rb +10 -18
  21. data/lib/action_view/helpers/form_tag_helper.rb +12 -9
  22. data/lib/action_view/helpers/javascript_helper.rb +7 -5
  23. data/lib/action_view/helpers/number_helper.rb +9 -8
  24. data/lib/action_view/helpers/output_safety_helper.rb +1 -1
  25. data/lib/action_view/helpers/rendering_helper.rb +17 -7
  26. data/lib/action_view/helpers/sanitize_helper.rb +10 -16
  27. data/lib/action_view/helpers/tag_helper.rb +94 -19
  28. data/lib/action_view/helpers/tags/base.rb +10 -7
  29. data/lib/action_view/helpers/tags/check_box.rb +0 -1
  30. data/lib/action_view/helpers/tags/collection_check_boxes.rb +0 -1
  31. data/lib/action_view/helpers/tags/collection_helpers.rb +0 -1
  32. data/lib/action_view/helpers/tags/collection_radio_buttons.rb +0 -1
  33. data/lib/action_view/helpers/tags/color_field.rb +0 -1
  34. data/lib/action_view/helpers/tags/date_field.rb +1 -2
  35. data/lib/action_view/helpers/tags/date_select.rb +2 -3
  36. data/lib/action_view/helpers/tags/datetime_field.rb +0 -1
  37. data/lib/action_view/helpers/tags/datetime_local_field.rb +1 -2
  38. data/lib/action_view/helpers/tags/label.rb +4 -1
  39. data/lib/action_view/helpers/tags/month_field.rb +1 -2
  40. data/lib/action_view/helpers/tags/radio_button.rb +0 -1
  41. data/lib/action_view/helpers/tags/select.rb +1 -2
  42. data/lib/action_view/helpers/tags/text_field.rb +0 -1
  43. data/lib/action_view/helpers/tags/time_field.rb +1 -2
  44. data/lib/action_view/helpers/tags/week_field.rb +1 -2
  45. data/lib/action_view/helpers/text_helper.rb +2 -3
  46. data/lib/action_view/helpers/translation_helper.rb +98 -51
  47. data/lib/action_view/helpers/url_helper.rb +124 -16
  48. data/lib/action_view/layouts.rb +8 -10
  49. data/lib/action_view/log_subscriber.rb +26 -11
  50. data/lib/action_view/lookup_context.rb +59 -31
  51. data/lib/action_view/path_set.rb +3 -12
  52. data/lib/action_view/railtie.rb +39 -41
  53. data/lib/action_view/record_identifier.rb +0 -1
  54. data/lib/action_view/renderer/abstract_renderer.rb +142 -11
  55. data/lib/action_view/renderer/collection_renderer.rb +196 -0
  56. data/lib/action_view/renderer/object_renderer.rb +34 -0
  57. data/lib/action_view/renderer/partial_renderer/collection_caching.rb +35 -29
  58. data/lib/action_view/renderer/partial_renderer.rb +21 -273
  59. data/lib/action_view/renderer/renderer.rb +59 -4
  60. data/lib/action_view/renderer/streaming_template_renderer.rb +9 -7
  61. data/lib/action_view/renderer/template_renderer.rb +35 -27
  62. data/lib/action_view/rendering.rb +49 -29
  63. data/lib/action_view/routing_url_for.rb +1 -1
  64. data/lib/action_view/template/error.rb +30 -15
  65. data/lib/action_view/template/handlers/builder.rb +2 -2
  66. data/lib/action_view/template/handlers/erb/erubi.rb +15 -9
  67. data/lib/action_view/template/handlers/erb.rb +14 -19
  68. data/lib/action_view/template/handlers/html.rb +1 -1
  69. data/lib/action_view/template/handlers/raw.rb +2 -2
  70. data/lib/action_view/template/handlers.rb +1 -1
  71. data/lib/action_view/template/html.rb +5 -6
  72. data/lib/action_view/template/inline.rb +22 -0
  73. data/lib/action_view/template/raw_file.rb +25 -0
  74. data/lib/action_view/template/renderable.rb +24 -0
  75. data/lib/action_view/template/resolver.rb +141 -140
  76. data/lib/action_view/template/sources/file.rb +17 -0
  77. data/lib/action_view/template/sources.rb +13 -0
  78. data/lib/action_view/template/text.rb +2 -3
  79. data/lib/action_view/template.rb +49 -75
  80. data/lib/action_view/test_case.rb +20 -28
  81. data/lib/action_view/testing/resolvers.rb +18 -27
  82. data/lib/action_view/unbound_template.rb +31 -0
  83. data/lib/action_view/view_paths.rb +59 -38
  84. data/lib/action_view.rb +7 -2
  85. data/lib/assets/compiled/rails-ujs.js +25 -16
  86. metadata +30 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58d19af0e853c217ca89f2167775195c7a44ebba26e4d9a682aabeb6a25b6af4
4
- data.tar.gz: 15d2c9faa90c17d33772df3ce0eacccecb090e7310af47ab1d82bca6448a2a11
3
+ metadata.gz: d032131f3879f298ee73bdec251c6b71bcf05c12bda0bb4a8156cb77096c8cb8
4
+ data.tar.gz: '034379d2e8c7d137f60fcc3044aef37b94f2d5f7b441d634f7e24f72f01c817d'
5
5
  SHA512:
6
- metadata.gz: dc169a10649b5f6cdfb8488bd16cbb7cab049081e7a6c53821cfab497e8035c7843c690e3bffcffc571bf2f610e5f2b7eee80283f622262d5ff9f1f20c8ef210
7
- data.tar.gz: ed371d7bec363bafe775d5a1ed3d11a1002f96589c142c662afabc1862c71314427fc07004d0bfa4bc2ac5078f0c0b38410ccca1ee738594223a1a3a336ffa14
6
+ metadata.gz: d8a6276b5517f7991936433c76543041c35a7521eae07ec5afd46db1b3fa7292aa15ed92b74784774a72ff5b7af8bf5e07c3bff70f4a25c5fb2d0ec55d2092d5
7
+ data.tar.gz: 940c438d6ce952627e2bc08a6d7272a6ceae8fe4b89095acc9daa889d8a8eb3f1ceced29ee4c9c3c8ffc41ed9104eae2be6a62c643eba66679d6ab744b125961
data/CHANGELOG.md CHANGED
@@ -1,191 +1,345 @@
1
- ## Rails 6.0.0.beta1 (January 18, 2019) ##
1
+ ## Rails 6.1.4 (June 24, 2021) ##
2
2
 
3
- * Remove deprecated `image_alt` helper.
3
+ * The `translate` helper now passes `default` values that aren't
4
+ translation keys through `I18n.translate` for interpolation.
5
+
6
+ *Jonathan Hefner*
7
+
8
+ * Don't attach UJS form submission handlers to Turbo forms.
9
+
10
+ *David Heinemeier Hansson*
11
+
12
+ * Allow both `current_page?(url_hash)` and `current_page?(**url_hash)` on Ruby 2.7.
13
+
14
+ *Ryuta Kamizono*
15
+
16
+
17
+ ## Rails 6.1.3.2 (May 05, 2021) ##
18
+
19
+ * No changes.
20
+
21
+
22
+ ## Rails 6.1.3.1 (March 26, 2021) ##
23
+
24
+ * No changes.
25
+
26
+
27
+ ## Rails 6.1.3 (February 17, 2021) ##
28
+
29
+ * No changes.
30
+
31
+
32
+ ## Rails 6.1.2.1 (February 10, 2021) ##
33
+
34
+ * No changes.
35
+
36
+
37
+ ## Rails 6.1.2 (February 09, 2021) ##
38
+
39
+ * No changes.
40
+
41
+
42
+ ## Rails 6.1.1 (January 07, 2021) ##
43
+
44
+ * Fix lazy translation in partial with block.
45
+
46
+ *Marek Kasztelnik*
47
+
48
+ * Avoid extra `SELECT COUNT` queries when rendering Active Record collections.
49
+
50
+ *aar0nr*
51
+
52
+ * Link preloading keep integrity hashes in the header.
53
+
54
+ *Étienne Barrié*
55
+
56
+ * Add `config.action_view.preload_links_header` to allow disabling of
57
+ the `Link` header being added by default when using `stylesheet_link_tag`
58
+ and `javascript_include_tag`.
59
+
60
+ *Andrew White*
61
+
62
+ * The `translate` helper now resolves `default` values when a `nil` key is
63
+ specified, instead of always returning `nil`.
64
+
65
+ *Jonathan Hefner*
66
+
67
+
68
+ ## Rails 6.1.0 (December 09, 2020) ##
69
+
70
+ * SanitizeHelper.sanitized_allowed_attributes and SanitizeHelper.sanitized_allowed_tags
71
+ call safe_list_sanitizer's class method
72
+
73
+ Fixes #39586
74
+
75
+ *Taufiq Muhammadi*
76
+
77
+ * Change form_with to generate non-remote forms by default.
78
+
79
+ `form_with` would generate a remote form by default. This would confuse
80
+ users because they were forced to handle remote requests.
81
+
82
+ All new 6.1 applications will generate non-remote forms by default.
83
+ When upgrading a 6.0 application you can enable remote forms by default by
84
+ setting `config.action_view.form_with_generates_remote_forms` to `true`.
85
+
86
+ *Petrik de Heus*
87
+
88
+ * Yield translated strings to calls of `ActionView::FormBuilder#button`
89
+ when a block is given.
90
+
91
+ *Sean Doyle*
92
+
93
+ * Alias `ActionView::Helpers::Tags::Label::LabelBuilder#translation` to
94
+ `#to_s` so that `form.label` calls can yield that value to their blocks.
95
+
96
+ *Sean Doyle*
97
+
98
+ * Rename the new `TagHelper#class_names` method to `TagHelper#token_list`,
99
+ and make the original available as an alias.
100
+
101
+ token_list("foo", "foo bar")
102
+ # => "foo bar"
103
+
104
+ *Sean Doyle*
105
+
106
+ * ARIA Array and Hash attributes are treated as space separated `DOMTokenList`
107
+ values. This is useful when declaring lists of label text identifiers in
108
+ `aria-labelledby` or `aria-describedby`.
109
+
110
+ tag.input type: 'checkbox', name: 'published', aria: {
111
+ invalid: @post.errors[:published].any?,
112
+ labelledby: ['published_context', 'published_label'],
113
+ describedby: { published_errors: @post.errors[:published].any? }
114
+ }
115
+ #=> <input
116
+ type="checkbox" name="published" aria-invalid="true"
117
+ aria-labelledby="published_context published_label"
118
+ aria-describedby="published_errors"
119
+ >
120
+
121
+ *Sean Doyle*
122
+
123
+ * Remove deprecated `escape_whitelist` from `ActionView::Template::Handlers::ERB`.
4
124
 
5
125
  *Rafael Mendonça França*
6
126
 
7
- * Fix the need of `#protect_against_forgery?` method defined in
8
- `ActionView::Base` subclasses. This prevents the use of forms and buttons.
127
+ * Remove deprecated `find_all_anywhere` from `ActionView::Resolver`.
9
128
 
10
- *Genadi Samokovarov*
129
+ *Rafael Mendonça França*
11
130
 
12
- * Fix UJS permanently showing disabled text in a[data-remote][data-disable-with] elements within forms.
13
- Fixes #33889
131
+ * Remove deprecated `formats` from `ActionView::Template::HTML`.
14
132
 
15
- *Wolfgang Hobmaier*
133
+ *Rafael Mendonça França*
16
134
 
17
- * Prevent non-primary mouse keys from triggering Rails UJS click handlers.
18
- Firefox fires click events even if the click was triggered by non-primary mouse keys such as right- or scroll-wheel-clicks.
19
- For example, right-clicking a link such as the one described below (with an underlying ajax request registered on click) should not cause that request to occur.
135
+ * Remove deprecated `formats` from `ActionView::Template::RawFile`.
20
136
 
21
- ```
22
- <%= link_to 'Remote', remote_path, class: 'remote', remote: true, data: { type: :json } %>
23
- ```
137
+ *Rafael Mendonça França*
24
138
 
25
- Fixes #34541
139
+ * Remove deprecated `formats` from `ActionView::Template::Text`.
26
140
 
27
- *Wolfgang Hobmaier*
141
+ *Rafael Mendonça França*
28
142
 
29
- * Prevent `ActionView::TextHelper#word_wrap` from unexpectedly stripping white space from the _left_ side of lines.
143
+ * Remove deprecated `find_file` from `ActionView::PathSet`.
30
144
 
31
- For example, given input like this:
145
+ *Rafael Mendonça França*
32
146
 
33
- ```
34
- This is a paragraph with an initial indent,
35
- followed by additional lines that are not indented,
36
- and finally terminated with a blockquote:
37
- "A pithy saying"
38
- ```
147
+ * Remove deprecated `rendered_format` from `ActionView::LookupContext`.
39
148
 
40
- Calling `word_wrap` should not trim the indents on the first and last lines.
149
+ *Rafael Mendonça França*
41
150
 
42
- Fixes #34487
151
+ * Remove deprecated `find_file` from `ActionView::ViewPaths`.
43
152
 
44
- *Lyle Mullican*
153
+ *Rafael Mendonça França*
45
154
 
46
- * Add allocations to template rendering instrumentation.
155
+ * Require that `ActionView::Base` subclasses implement `#compiled_method_container`.
47
156
 
48
- Adds the allocations for template and partial rendering to the server output on render.
157
+ *Rafael Mendonça França*
49
158
 
50
- ```
51
- Rendered posts/_form.html.erb (Duration: 7.1ms | Allocations: 6004)
52
- Rendered posts/new.html.erb within layouts/application (Duration: 8.3ms | Allocations: 6654)
53
- Completed 200 OK in 858ms (Views: 848.4ms | ActiveRecord: 0.4ms | Allocations: 1539564)
54
- ```
159
+ * Remove deprecated support to pass an object that is not a `ActionView::LookupContext` as the first argument
160
+ in `ActionView::Base#initialize`.
55
161
 
56
- *Eileen M. Uchitelle*, *Aaron Patterson*
162
+ *Rafael Mendonça França*
57
163
 
58
- * Respect the `only_path` option passed to `url_for` when the options are passed in as an array
164
+ * Remove deprecated `format` argument `ActionView::Base#initialize`.
59
165
 
60
- Fixes #33237.
166
+ *Rafael Mendonça França*
61
167
 
62
- *Joel Ambass*
168
+ * Remove deprecated `ActionView::Template#refresh`.
63
169
 
64
- * Deprecate calling private model methods from view helpers.
170
+ *Rafael Mendonça França*
65
171
 
66
- For example, in methods like `options_from_collection_for_select`
67
- and `collection_select` it is possible to call private methods from
68
- the objects used.
172
+ * Remove deprecated `ActionView::Template#original_encoding`.
69
173
 
70
- Fixes #33546.
174
+ *Rafael Mendonça França*
71
175
 
72
- *Ana María Martínez Gómez*
176
+ * Remove deprecated `ActionView::Template#variants`.
73
177
 
74
- * Fix issue with `button_to`'s `to_form_params`
178
+ *Rafael Mendonça França*
75
179
 
76
- `button_to` was throwing exception when invoked with `params` hash that
77
- contains symbol and string keys. The reason for the exception was that
78
- `to_form_params` was comparing the given symbol and string keys.
180
+ * Remove deprecated `ActionView::Template#formats`.
79
181
 
80
- The issue is fixed by turning all keys to strings inside
81
- `to_form_params` before comparing them.
182
+ *Rafael Mendonça França*
82
183
 
83
- *Georgi Georgiev*
184
+ * Remove deprecated `ActionView::Template#virtual_path=`.
84
185
 
85
- * Mark arrays of translations as trusted safe by using the `_html` suffix.
186
+ *Rafael Mendonça França*
86
187
 
87
- Example:
188
+ * Remove deprecated `ActionView::Template#updated_at`.
88
189
 
89
- en:
90
- foo_html:
91
- - "One"
92
- - "<strong>Two</strong>"
93
- - "Three &#128075; &#128578;"
190
+ *Rafael Mendonça França*
94
191
 
95
- *Juan Broullon*
192
+ * Remove deprecated `updated_at` argument required on `ActionView::Template#initialize`.
96
193
 
97
- * Add `year_format` option to date_select tag. This option makes it possible to customize year
98
- names. Lambda should be passed to use this option.
194
+ *Rafael Mendonça França*
99
195
 
100
- Example:
196
+ * Make `locals` argument required on `ActionView::Template#initialize`.
101
197
 
102
- date_select('user_birthday', '', start_year: 1998, end_year: 2000, year_format: ->year { "Heisei #{year - 1988}" })
198
+ *Rafael Mendonça França*
103
199
 
104
- The HTML produced:
200
+ * Remove deprecated `ActionView::Template.finalize_compiled_template_methods`.
105
201
 
106
- <select id="user_birthday__1i" name="user_birthday[(1i)]">
107
- <option value="1998">Heisei 10</option>
108
- <option value="1999">Heisei 11</option>
109
- <option value="2000">Heisei 12</option>
110
- </select>
111
- /* The rest is omitted */
202
+ *Rafael Mendonça França*
112
203
 
113
- *Koki Ryu*
204
+ * Remove deprecated `config.action_view.finalize_compiled_template_methods`
114
205
 
115
- * Fix JavaScript views rendering does not work with Firefox when using
116
- Content Security Policy.
206
+ *Rafael Mendonça França*
117
207
 
118
- Fixes #32577.
208
+ * Remove deprecated support to calling `ActionView::ViewPaths#with_fallback` with a block.
119
209
 
120
- *Yuji Yaginuma*
210
+ *Rafael Mendonça França*
121
211
 
122
- * Add the `nonce: true` option for `javascript_include_tag` helper to
123
- support automatic nonce generation for Content Security Policy.
124
- Works the same way as `javascript_tag nonce: true` does.
212
+ * Remove deprecated support to passing absolute paths to `render template:`.
125
213
 
126
- *Yaroslav Markin*
214
+ *Rafael Mendonça França*
127
215
 
128
- * Remove `ActionView::Helpers::RecordTagHelper`.
216
+ * Remove deprecated support to passing relative paths to `render file:`.
129
217
 
130
- *Yoshiyuki Hirano*
218
+ *Rafael Mendonça França*
131
219
 
132
- * Disable `ActionView::Template` finalizers in test environment.
220
+ * Remove support to template handlers that don't accept two arguments.
133
221
 
134
- Template finalization can be expensive in large view test suites.
135
- Add a configuration option,
136
- `action_view.finalize_compiled_template_methods`, and turn it off in
137
- the test environment.
222
+ *Rafael Mendonça França*
138
223
 
139
- *Simon Coffey*
224
+ * Remove deprecated pattern argument in `ActionView::Template::PathResolver`.
140
225
 
141
- * Extract the `confirm` call in its own, overridable method in `rails_ujs`.
226
+ *Rafael Mendonça França*
142
227
 
143
- Example:
228
+ * Remove deprecated support to call private methods from object in some view helpers.
144
229
 
145
- Rails.confirm = function(message, element) {
146
- return (my_bootstrap_modal_confirm(message));
147
- }
230
+ *Rafael Mendonça França*
148
231
 
149
- *Mathieu Mahé*
232
+ * `ActionView::Helpers::TranslationHelper#translate` accepts a block, yielding
233
+ the translated text and the fully resolved translation key:
150
234
 
151
- * Enable select tag helper to mark `prompt` option as `selected` and/or `disabled` for `required`
152
- field.
235
+ <%= translate(".relative_key") do |translation, resolved_key| %>
236
+ <span title="<%= resolved_key %>"><%= translation %></span>
237
+ <% end %>
153
238
 
154
- Example:
239
+ *Sean Doyle*
155
240
 
156
- select :post,
157
- :category,
158
- ["lifestyle", "programming", "spiritual"],
159
- { selected: "", disabled: "", prompt: "Choose one" },
160
- { required: true }
241
+ * Ensure cache fragment digests include all relevant template dependencies when
242
+ fragments are contained in a block passed to the render helper. Remove the
243
+ virtual_path keyword arguments found in CacheHelper as they no longer possess
244
+ any function following 1581cab.
161
245
 
162
- Placeholder option would be selected and disabled.
246
+ Fixes #38984.
163
247
 
164
- The HTML produced:
248
+ *Aaron Lipman*
165
249
 
166
- <select required="required" name="post[category]" id="post_category">
167
- <option disabled="disabled" selected="selected" value="">Choose one</option>
168
- <option value="lifestyle">lifestyle</option>
169
- <option value="programming">programming</option>
170
- <option value="spiritual">spiritual</option></select>
250
+ * Deprecate `config.action_view.raise_on_missing_translations` in favor of
251
+ `config.i18n.raise_on_missing_translations`.
171
252
 
172
- *Sergey Prikhodko*
253
+ New generalized configuration option now determines whether an error should be raised
254
+ for missing translations in controllers and views.
173
255
 
174
- * Don't enforce UTF-8 by default.
256
+ *fatkodima*
175
257
 
176
- With the disabling of TLS 1.0 by most major websites, continuing to run
177
- IE8 or lower becomes increasingly difficult so default to not enforcing
178
- UTF-8 encoding as it's not relevant to other browsers.
258
+ * Instrument layout rendering in `TemplateRenderer#render_with_layout` as `render_layout.action_view`,
259
+ and include (when necessary) the layout's virtual path in notification payloads for collection and partial renders.
179
260
 
180
- *Andrew White*
261
+ *Zach Kemp*
262
+
263
+ * `ActionView::Base.annotate_rendered_view_with_filenames` annotates HTML output with template file names.
264
+
265
+ *Joel Hawksley*, *Aaron Patterson*
266
+
267
+ * `ActionView::Helpers::TranslationHelper#translate` returns nil when
268
+ passed `default: nil` without a translation matching `I18n#translate`.
269
+
270
+ *Stefan Wrobel*
271
+
272
+ * `OptimizedFileSystemResolver` prefers template details in order of locale,
273
+ formats, variants, handlers.
274
+
275
+ *Iago Pimenta*
276
+
277
+ * Added `class_names` helper to create a CSS class value with conditional classes.
278
+
279
+ *Joel Hawksley*, *Aaron Patterson*
280
+
281
+ * Add support for conditional values to TagBuilder.
282
+
283
+ *Joel Hawksley*
284
+
285
+ * `ActionView::Helpers::FormOptionsHelper#select` should mark option for `nil` as selected.
286
+
287
+ ```ruby
288
+ @post = Post.new
289
+ @post.category = nil
290
+
291
+ # Before
292
+ select("post", "category", none: nil, programming: 1, economics: 2)
293
+ # =>
294
+ # <select name="post[category]" id="post_category">
295
+ # <option value="">none</option>
296
+ # <option value="1">programming</option>
297
+ # <option value="2">economics</option>
298
+ # </select>
299
+
300
+ # After
301
+ select("post", "category", none: nil, programming: 1, economics: 2)
302
+ # =>
303
+ # <select name="post[category]" id="post_category">
304
+ # <option selected="selected" value="">none</option>
305
+ # <option value="1">programming</option>
306
+ # <option value="2">economics</option>
307
+ # </select>
308
+ ```
309
+
310
+ *bogdanvlviv*
311
+
312
+ * Log lines for partial renders and started template renders are now
313
+ emitted at the `DEBUG` level instead of `INFO`.
314
+
315
+ Completed template renders are still logged at the `INFO` level.
316
+
317
+ *DHH*
318
+
319
+ * ActionView::Helpers::SanitizeHelper: support rails-html-sanitizer 1.1.0.
320
+
321
+ *Juanito Fatas*
322
+
323
+ * Added `phone_to` helper method to create a link from mobile numbers.
324
+
325
+ *Pietro Moro*
326
+
327
+ * annotated_source_code returns an empty array so TemplateErrors without a
328
+ template in the backtrace are surfaced properly by DebugExceptions.
329
+
330
+ *Guilherme Mansur*, *Kasper Timm Hansen*
331
+
332
+ * Add autoload for SyntaxErrorInTemplate so syntax errors are correctly raised by DebugExceptions.
333
+
334
+ *Guilherme Mansur*, *Gannon McGibbon*
181
335
 
182
- * Change translation key of `submit_tag` from `module_name_class_name` to `module_name/class_name`.
336
+ * `RenderingHelper` supports rendering objects that `respond_to?` `:render_in`.
183
337
 
184
- *Rui Onodera*
338
+ *Joel Hawksley*, *Natasha Umer*, *Aaron Patterson*, *Shawn Allen*, *Emily Plummer*, *Diana Mounter*, *John Hawthorn*, *Nathan Herald*, *Zaid Zawaideh*, *Zach Ahn*
185
339
 
186
- * Rails 6 requires Ruby 2.5.0 or newer.
340
+ * Fix `select_tag` so that it doesn't change `options` when `include_blank` is present.
187
341
 
188
- *Jeremy Daer*, *Kasper Timm Hansen*
342
+ *Younes SERRAJ*
189
343
 
190
344
 
191
- Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/actionview/CHANGELOG.md) for previous changes.
345
+ Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/actionview/CHANGELOG.md) for previous changes.
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2004-2019 David Heinemeier Hansson
1
+ Copyright (c) 2004-2020 David Heinemeier Hansson
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -5,6 +5,8 @@ view helpers that assist when building HTML forms, Atom feeds and more.
5
5
  Template formats that Action View handles are ERB (embedded Ruby, typically
6
6
  used to inline short Ruby snippets inside HTML), and XML Builder.
7
7
 
8
+ You can read more about Action View in the {Action View Overview}[https://edgeguides.rubyonrails.org/action_view_overview.html] guide.
9
+
8
10
  == Download and installation
9
11
 
10
12
  The latest version of Action View can be installed with RubyGems:
@@ -13,7 +15,7 @@ The latest version of Action View can be installed with RubyGems:
13
15
 
14
16
  Source code can be downloaded as part of the Rails project on GitHub:
15
17
 
16
- * https://github.com/rails/rails/tree/master/actionview
18
+ * https://github.com/rails/rails/tree/main/actionview
17
19
 
18
20
 
19
21
  == License
@@ -27,7 +29,7 @@ Action View is released under the MIT license:
27
29
 
28
30
  API documentation is at
29
31
 
30
- * http://api.rubyonrails.org
32
+ * https://api.rubyonrails.org
31
33
 
32
34
  Bug reports for the Ruby on Rails project can be filed here:
33
35
 
@@ -35,4 +37,4 @@ Bug reports for the Ruby on Rails project can be filed here:
35
37
 
36
38
  Feature requests should be discussed on the rails-core mailing list here:
37
39
 
38
- * https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-core
40
+ * https://discuss.rubyonrails.org/c/rubyonrails-core
@@ -27,7 +27,7 @@ module ActionView #:nodoc:
27
27
  # Name: <%= person.name %><br/>
28
28
  # <% end %>
29
29
  #
30
- # The loop is setup in regular embedding tags <tt><% %></tt>, and the name is written using the output embedding tag <tt><%= %></tt>. Note that this
30
+ # The loop is set up in regular embedding tags <tt><% %></tt>, and the name is written using the output embedding tag <tt><%= %></tt>. Note that this
31
31
  # is not just a usage suggestion. Regular output functions like print or puts won't work with ERB templates. So this would be wrong:
32
32
  #
33
33
  # <%# WRONG %>
@@ -151,7 +151,7 @@ module ActionView #:nodoc:
151
151
  # Specify whether rendering within namespaced controllers should prefix
152
152
  # the partial paths for ActiveModel objects with the namespace.
153
153
  # (e.g., an Admin::PostsController would render @post using /admin/posts/_post.erb)
154
- cattr_accessor :prefix_partial_path_with_controller_namespace, default: true
154
+ class_attribute :prefix_partial_path_with_controller_namespace, default: true
155
155
 
156
156
  # Specify default_formats that can be rendered.
157
157
  cattr_accessor :default_formats
@@ -162,6 +162,9 @@ module ActionView #:nodoc:
162
162
  # Specify whether submit_tag should automatically disable on click
163
163
  cattr_accessor :automatically_disable_submit_tag, default: true
164
164
 
165
+ # Annotate rendered view with file names
166
+ cattr_accessor :annotate_rendered_view_with_filenames, default: false
167
+
165
168
  class_attribute :_routes
166
169
  class_attribute :logger
167
170
 
@@ -179,37 +182,100 @@ module ActionView #:nodoc:
179
182
  def xss_safe? #:nodoc:
180
183
  true
181
184
  end
185
+
186
+ def with_empty_template_cache # :nodoc:
187
+ subclass = Class.new(self) {
188
+ # We can't implement these as self.class because subclasses will
189
+ # share the same template cache as superclasses, so "changed?" won't work
190
+ # correctly.
191
+ define_method(:compiled_method_container) { subclass }
192
+ define_singleton_method(:compiled_method_container) { subclass }
193
+
194
+ def inspect
195
+ "#<ActionView::Base:#{'%#016x' % (object_id << 1)}>"
196
+ end
197
+ }
198
+ end
199
+
200
+ def changed?(other) # :nodoc:
201
+ compiled_method_container != other.compiled_method_container
202
+ end
182
203
  end
183
204
 
184
- attr_accessor :view_renderer
205
+ attr_reader :view_renderer, :lookup_context
185
206
  attr_internal :config, :assigns
186
207
 
187
- delegate :lookup_context, to: :view_renderer
188
208
  delegate :formats, :formats=, :locale, :locale=, :view_paths, :view_paths=, to: :lookup_context
189
209
 
190
210
  def assign(new_assigns) # :nodoc:
191
211
  @_assigns = new_assigns.each { |key, value| instance_variable_set("@#{key}", value) }
192
212
  end
193
213
 
194
- def initialize(context = nil, assigns = {}, controller = nil, formats = nil) #:nodoc:
214
+ # :stopdoc:
215
+
216
+ def self.empty
217
+ with_view_paths([])
218
+ end
219
+
220
+ def self.with_view_paths(view_paths, assigns = {}, controller = nil)
221
+ with_context ActionView::LookupContext.new(view_paths), assigns, controller
222
+ end
223
+
224
+ def self.with_context(context, assigns = {}, controller = nil)
225
+ new context, assigns, controller
226
+ end
227
+
228
+ # :startdoc:
229
+
230
+ def initialize(lookup_context, assigns, controller) #:nodoc:
195
231
  @_config = ActiveSupport::InheritableOptions.new
196
232
 
197
- if context.is_a?(ActionView::Renderer)
198
- @view_renderer = context
199
- else
200
- lookup_context = context.is_a?(ActionView::LookupContext) ?
201
- context : ActionView::LookupContext.new(context)
202
- lookup_context.formats = formats if formats
203
- lookup_context.prefixes = controller._prefixes if controller
204
- @view_renderer = ActionView::Renderer.new(lookup_context)
205
- end
233
+ @lookup_context = lookup_context
234
+
235
+ @view_renderer = ActionView::Renderer.new @lookup_context
236
+ @current_template = nil
206
237
 
207
- @cache_hit = {}
208
238
  assign(assigns)
209
239
  assign_controller(controller)
210
240
  _prepare_context
211
241
  end
212
242
 
243
+ def _run(method, template, locals, buffer, add_to_stack: true, &block)
244
+ _old_output_buffer, _old_virtual_path, _old_template = @output_buffer, @virtual_path, @current_template
245
+ @current_template = template if add_to_stack
246
+ @output_buffer = buffer
247
+ public_send(method, locals, buffer, &block)
248
+ ensure
249
+ @output_buffer, @virtual_path, @current_template = _old_output_buffer, _old_virtual_path, _old_template
250
+ end
251
+
252
+ def compiled_method_container
253
+ raise NotImplementedError, <<~msg.squish
254
+ Subclasses of ActionView::Base must implement `compiled_method_container`
255
+ or use the class method `with_empty_template_cache` for constructing
256
+ an ActionView::Base subclass that has an empty cache.
257
+ msg
258
+ end
259
+
260
+ def in_rendering_context(options)
261
+ old_view_renderer = @view_renderer
262
+ old_lookup_context = @lookup_context
263
+
264
+ if !lookup_context.html_fallback_for_js && options[:formats]
265
+ formats = Array(options[:formats])
266
+ if formats == [:js]
267
+ formats << :html
268
+ end
269
+ @lookup_context = lookup_context.with_prepended_formats(formats)
270
+ @view_renderer = ActionView::Renderer.new @lookup_context
271
+ end
272
+
273
+ yield @view_renderer
274
+ ensure
275
+ @view_renderer = old_view_renderer
276
+ @lookup_context = old_lookup_context
277
+ end
278
+
213
279
  ActiveSupport.run_load_hooks(:action_view, self)
214
280
  end
215
281
  end