actionview 7.1.2 → 8.0.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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +51 -382
  3. data/lib/action_view/base.rb +25 -11
  4. data/lib/action_view/cache_expiry.rb +9 -3
  5. data/lib/action_view/dependency_tracker/erb_tracker.rb +36 -27
  6. data/lib/action_view/dependency_tracker/ruby_tracker.rb +43 -0
  7. data/lib/action_view/dependency_tracker/wildcard_resolver.rb +32 -0
  8. data/lib/action_view/dependency_tracker.rb +2 -1
  9. data/lib/action_view/digestor.rb +6 -2
  10. data/lib/action_view/gem_version.rb +2 -2
  11. data/lib/action_view/helpers/asset_tag_helper.rb +18 -6
  12. data/lib/action_view/helpers/atom_feed_helper.rb +0 -2
  13. data/lib/action_view/helpers/cache_helper.rb +14 -6
  14. data/lib/action_view/helpers/csrf_helper.rb +1 -1
  15. data/lib/action_view/helpers/date_helper.rb +3 -3
  16. data/lib/action_view/helpers/form_helper.rb +282 -273
  17. data/lib/action_view/helpers/form_options_helper.rb +23 -21
  18. data/lib/action_view/helpers/form_tag_helper.rb +104 -69
  19. data/lib/action_view/helpers/number_helper.rb +35 -329
  20. data/lib/action_view/helpers/output_safety_helper.rb +5 -6
  21. data/lib/action_view/helpers/rendering_helper.rb +160 -50
  22. data/lib/action_view/helpers/sanitize_helper.rb +31 -14
  23. data/lib/action_view/helpers/tag_helper.rb +196 -19
  24. data/lib/action_view/helpers/tags/collection_check_boxes.rb +4 -3
  25. data/lib/action_view/helpers/tags/collection_helpers.rb +2 -1
  26. data/lib/action_view/helpers/text_helper.rb +125 -69
  27. data/lib/action_view/helpers/url_helper.rb +6 -80
  28. data/lib/action_view/layouts.rb +11 -13
  29. data/lib/action_view/log_subscriber.rb +8 -4
  30. data/lib/action_view/railtie.rb +0 -1
  31. data/lib/action_view/record_identifier.rb +1 -1
  32. data/lib/action_view/render_parser/prism_render_parser.rb +139 -0
  33. data/lib/action_view/{ripper_ast_parser.rb → render_parser/ripper_render_parser.rb} +162 -10
  34. data/lib/action_view/render_parser.rb +21 -169
  35. data/lib/action_view/renderer/abstract_renderer.rb +1 -1
  36. data/lib/action_view/renderer/partial_renderer.rb +2 -2
  37. data/lib/action_view/renderer/renderer.rb +32 -38
  38. data/lib/action_view/renderer/streaming_template_renderer.rb +0 -1
  39. data/lib/action_view/renderer/template_renderer.rb +3 -3
  40. data/lib/action_view/rendering.rb +6 -7
  41. data/lib/action_view/template/error.rb +11 -0
  42. data/lib/action_view/template/handlers/erb.rb +45 -37
  43. data/lib/action_view/template/renderable.rb +7 -1
  44. data/lib/action_view/template/resolver.rb +0 -3
  45. data/lib/action_view/template.rb +46 -12
  46. data/lib/action_view/test_case.rb +14 -16
  47. data/lib/action_view/unbound_template.rb +4 -4
  48. data/lib/action_view.rb +1 -1
  49. metadata +17 -19
  50. data/lib/action_view/dependency_tracker/ripper_tracker.rb +0 -59
  51. data/lib/assets/compiled/rails-ujs.js +0 -777
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ec34555888d78ec7dd238a5845d5a0a6861aabf4b43b532b9001de74d7f69f8
4
- data.tar.gz: fa36f1e81bea968392435051307a0ad371e856f8fa4760b6e341df5412a017e5
3
+ metadata.gz: cc81c16e4d502ce1736e2ff17c85dbb50ed6209d6ded187af4f846d05540f551
4
+ data.tar.gz: faa7c34dff4cfc391389c56b52afd0cbbbdbaf5ee7805ae3e1d1fd78940f1195
5
5
  SHA512:
6
- metadata.gz: 229637c660fba19dcba6f8e15e83cf748b1e8ee0c123bc32d2b0417265df296254dfd3f9ef07d64b930f96c1e1b94a3ad9f9304a9c9e4ce734357208924019f7
7
- data.tar.gz: 5ef080a91aa2611698efca00142c79aa3f005ab680cbe804c41636df0318f05ce432429a3420d06515be43f2d249e7d38d8b9e7496d64b58a9ba218451310808
6
+ metadata.gz: 1e9c0c527c580719aea26c3a8499d1b1b82e4da5074271403c0060d0d96b604e23fe953ae8ede37d901ba7830fd3700a82297be2d29d574845eb79b559277d0f
7
+ data.tar.gz: 24a3fc73c41d00476204519044e278f8c545db961ac02e88d810325f6cc7d831d410e203e1691767b1cca6672c0ab2d0c5b19179276c47a672b8489827d0545d
data/CHANGELOG.md CHANGED
@@ -1,438 +1,107 @@
1
- ## Rails 7.1.2 (November 10, 2023) ##
2
-
3
- * Fix the `number_to_human_size` view helper to correctly work with negative numbers.
4
-
5
- *Earlopain*
6
-
7
- * Automatically discard the implicit locals injected by collection rendering for template that can't accept them
8
-
9
- When rendering a collection, two implicit variables are injected, which breaks templates with strict locals.
10
-
11
- Now they are only passed if the template will actually accept them.
12
-
13
- *Yasha Krasnou*, *Jean Boussier*
14
-
15
- * Fix `@rails/ujs` calling `start()` an extra time when using bundlers
16
-
17
- *Hartley McGuire*, *Ryunosuke Sato*
18
-
19
- * Fix the `capture` view helper compatibility with HAML and Slim
20
-
21
- When a blank string was captured in HAML or Slim (and possibly other template engines)
22
- it would instead return the entire buffer.
23
-
24
- *Jean Boussier*
25
-
26
-
27
- ## Rails 7.1.1 (October 11, 2023) ##
28
-
29
- * Updated `@rails/ujs` files to ignore certain data-* attributes when element is contenteditable.
30
-
31
- This fix was already landed in >= 7.0.4.3, < 7.1.0.
32
- [[CVE-2023-23913](https://github.com/advisories/GHSA-xp5h-f8jf-rc8q)]
33
-
34
- *Ryunosuke Sato*
35
-
36
-
37
- ## Rails 7.1.0 (October 05, 2023) ##
1
+ ## Rails 8.0.2 (March 12, 2025) ##
38
2
 
39
3
  * No changes.
40
4
 
41
5
 
42
- ## Rails 7.1.0.rc2 (October 01, 2023) ##
43
-
44
- * No changes.
45
-
46
-
47
- ## Rails 7.1.0.rc1 (September 27, 2023) ##
48
-
49
- * Introduce `ActionView::TestCase.register_parser`
50
-
51
- ```ruby
52
- register_parser :rss, -> rendered { RSS::Parser.parse(rendered) }
53
-
54
- test "renders RSS" do
55
- article = Article.create!(title: "Hello, world")
56
-
57
- render formats: :rss, partial: article
58
-
59
- assert_equal "Hello, world", rendered.rss.items.last.title
60
- end
61
- ```
62
-
63
- By default, register parsers for `:html` and `:json`.
64
-
65
- *Sean Doyle*
66
-
67
-
68
- ## Rails 7.1.0.beta1 (September 13, 2023) ##
69
-
70
- * Fix `simple_format` with blank `wrapper_tag` option returns plain html tag
71
-
72
- By default `simple_format` method returns the text wrapped with `<p>`. But if we explicitly specify
73
- the `wrapper_tag: nil` in the options, it returns the text wrapped with `<></>` tag.
74
-
75
- Before:
76
-
77
- ```ruby
78
- simple_format("Hello World", {}, { wrapper_tag: nil })
79
- # <>Hello World</>
80
- ```
81
-
82
- After:
6
+ ## Rails 8.0.2 (March 12, 2025) ##
83
7
 
84
- ```ruby
85
- simple_format("Hello World", {}, { wrapper_tag: nil })
86
- # <p>Hello World</p>
87
- ```
8
+ * Respect `html_options[:form]` when `collection_checkboxes` generates the
9
+ hidden `<input>`.
88
10
 
89
- *Akhil G Krishnan*, *Junichi Ito*
11
+ *Riccardo Odone*
90
12
 
91
- * Don't double-encode nested `field_id` and `field_name` index values
13
+ * Layouts have access to local variables passed to `render`.
92
14
 
93
- Pass `index: @options` as a default keyword argument to `field_id` and
94
- `field_name` view helper methods.
15
+ This fixes #31680 which was a regression in Rails 5.1.
95
16
 
96
- *Sean Doyle*
17
+ *Mike Dalessio*
97
18
 
98
- * Allow opting in/out of `Link preload` headers when calling `stylesheet_link_tag` or `javascript_include_tag`
19
+ * Argument errors related to strict locals in templates now raise an
20
+ `ActionView::StrictLocalsError`, and all other argument errors are reraised as-is.
99
21
 
100
- ```ruby
101
- # will exclude header, even if setting is enabled:
102
- javascript_include_tag("http://example.com/all.js", preload_links_header: false)
22
+ Previously, any `ArgumentError` raised during template rendering was swallowed during strict
23
+ local error handling, so that an `ArgumentError` unrelated to strict locals (e.g., a helper
24
+ method invoked with incorrect arguments) would be replaced by a similar `ArgumentError` with an
25
+ unrelated backtrace, making it difficult to debug templates.
103
26
 
104
- # will include header, even if setting is disabled:
105
- stylesheet_link_tag("http://example.com/all.js", preload_links_header: true)
106
- ```
27
+ Now, any `ArgumentError` unrelated to strict locals is reraised, preserving the original
28
+ backtrace for developers.
107
29
 
108
- *Alex Ghiculescu*
30
+ Also note that `ActionView::StrictLocalsError` is a subclass of `ArgumentError`, so any existing
31
+ code that rescues `ArgumentError` will continue to work.
109
32
 
110
- * Stop generating `Link preload` headers once it has reached 1KB.
33
+ Fixes #52227.
111
34
 
112
- Some proxies have trouble handling large headers, but more importantly preload links
113
- have diminishing returns so it's preferable not to go overboard with them.
35
+ *Mike Dalessio*
114
36
 
115
- If tighter control is needed, it's recommended to disable automatic generation of preloads
116
- and to generate them manually from the controller or from a middleware.
37
+ * Fix stack overflow error in dependency tracker when dealing with circular dependencies
117
38
 
118
39
  *Jean Boussier*
119
40
 
120
- * `simple_format` helper now handles a `:sanitize_options` - any extra options you want appending to the sanitize.
41
+ ## Rails 8.0.1 (December 13, 2024) ##
121
42
 
122
- Before:
123
- ```ruby
124
- simple_format("<a target=\"_blank\" href=\"http://example.com\">Continue</a>")
125
- # => "<p><a href=\"http://example.com\">Continue</a></p>"
126
- ```
43
+ * Fix a crash in ERB template error highlighting when the error occurs on a
44
+ line in the compiled template that is past the end of the source template.
127
45
 
128
- After:
129
- ```ruby
130
- simple_format("<a target=\"_blank\" href=\"http://example.com\">Continue</a>", {}, { sanitize_options: { attributes: %w[target href] } })
131
- # => "<p><a target=\"_blank\" href=\"http://example.com\">Continue</a></p>"
132
- ```
46
+ *Martin Emde*
133
47
 
134
- *Andrei Andriichuk*
48
+ * Improve reliability of ERB template error highlighting.
49
+ Fix infinite loops and crashes in highlighting and
50
+ improve tolerance for alternate ERB handlers.
135
51
 
136
- * Add support for HTML5 standards-compliant sanitizers, and default to `Rails::HTML5::Sanitizer`
137
- in the Rails 7.1 configuration if it is supported.
52
+ *Martin Emde*
138
53
 
139
- Action View's HTML sanitizers can be configured by setting
140
- `config.action_view.sanitizer_vendor`. Supported values are `Rails::HTML4::Sanitizer` or
141
- `Rails::HTML5::Sanitizer`.
142
54
 
143
- The Rails 7.1 configuration will set this to `Rails::HTML5::Sanitizer` when it is supported, and
144
- fall back to `Rails::HTML4::Sanitizer`. Previous configurations default to
145
- `Rails::HTML4::Sanitizer`.
55
+ ## Rails 8.0.0.1 (December 10, 2024) ##
146
56
 
147
- *Mike Dalessio*
57
+ * No changes.
148
58
 
149
- * `config.dom_testing_default_html_version` controls the HTML parser used by
150
- `ActionView::TestCase#document_root_element`, which creates the DOM used by the assertions in
151
- Rails::Dom::Testing.
152
59
 
153
- The Rails 7.1 default configuration opts into the HTML5 parser when it is supported, to better
154
- represent what the DOM would be in a browser user agent. Previously this test helper always used
155
- Nokogiri's HTML4 parser.
60
+ ## Rails 8.0.0 (November 07, 2024) ##
156
61
 
157
- *Mike Dalessio*
62
+ * No changes.
158
63
 
159
- * Add support for the HTML picture tag. It supports passing a String, an Array or a Block.
160
- Supports passing properties directly to the img tag via the `:image` key.
161
- Since the picture tag requires an img tag, the last element you provide will be used for the img tag.
162
- For complete control over the picture tag, a block can be passed, which will populate the contents of the tag accordingly.
163
64
 
164
- Can be used like this for a single source:
165
- ```erb
166
- <%= picture_tag("picture.webp") %>
167
- ```
168
- which will generate the following:
169
- ```html
170
- <picture>
171
- <img src="/images/picture.webp" />
172
- </picture>
173
- ```
65
+ ## Rails 8.0.0.rc2 (October 30, 2024) ##
174
66
 
175
- For multiple sources:
176
- ```erb
177
- <%= picture_tag("picture.webp", "picture.png", :class => "mt-2", :image => { alt: "Image", class: "responsive-img" }) %>
178
- ```
179
- will generate:
180
- ```html
181
- <picture class="mt-2">
182
- <source srcset="/images/picture.webp" />
183
- <source srcset="/images/picture.png" />
184
- <img alt="Image" class="responsive-img" src="/images/picture.png" />
185
- </picture>
186
- ```
67
+ * No changes.
187
68
 
188
- Full control via a block:
189
- ```erb
190
- <%= picture_tag(:class => "my-class") do %>
191
- <%= tag(:source, :srcset => image_path("picture.webp")) %>
192
- <%= tag(:source, :srcset => image_path("picture.png")) %>
193
- <%= image_tag("picture.png", :alt => "Image") %>
194
- <% end %>
195
- ```
196
- will generate:
197
- ```html
198
- <picture class="my-class">
199
- <source srcset="/images/picture.webp" />
200
- <source srcset="/images/picture.png" />
201
- <img alt="Image" src="/images/picture.png" />
202
- </picture>
203
- ```
204
69
 
205
- *Juan Pablo Balarini*
70
+ ## Rails 8.0.0.rc1 (October 19, 2024) ##
206
71
 
207
- * Remove deprecated support to passing instance variables as locals to partials.
72
+ * Remove deprecated support to passing a content to void tag elements on the `tag` builder.
208
73
 
209
74
  *Rafael Mendonça França*
210
75
 
211
- * Remove deprecated constant `ActionView::Path`.
76
+ * Remove deprecated support to passing `nil` to the `model:` argument of `form_with`.
212
77
 
213
78
  *Rafael Mendonça França*
214
79
 
215
- * Guard `token_list` calls from escaping HTML too often
216
-
217
- *Sean Doyle*
218
-
219
- * `select` can now be called with a single hash containing options and some HTML options
220
80
 
221
- Previously this would not work as expected:
81
+ ## Rails 8.0.0.beta1 (September 26, 2024) ##
222
82
 
223
- ```erb
224
- <%= select :post, :author, authors, required: true %>
225
- ```
226
-
227
- Instead you needed to do this:
83
+ * Enable DependencyTracker to evaluate renders with trailing interpolation.
228
84
 
229
85
  ```erb
230
- <%= select :post, :author, authors, {}, required: true %>
86
+ <%= render "maintenance_tasks/runs/info/#{run.status}" %>
231
87
  ```
232
88
 
233
- Now, either form is accepted, for the following HTML attributes: `required`, `multiple`, `size`.
89
+ Previously, the DependencyTracker would ignore this render, but now it will
90
+ mark all partials in the "maintenance_tasks/runs/info" folder as
91
+ dependencies.
234
92
 
235
- *Alex Ghiculescu*
93
+ *Hartley McGuire*
236
94
 
237
- * Datetime form helpers (`time_field`, `date_field`, `datetime_field`, `week_field`, `month_field`) now accept an instance of Time/Date/DateTime as `:value` option.
238
-
239
- Before:
240
- ```erb
241
- <%= form.datetime_field :written_at, value: Time.current.strftime("%Y-%m-%dT%T") %>
242
- ```
243
-
244
- After:
245
- ```erb
246
- <%= form.datetime_field :written_at, value: Time.current %>
247
- ```
248
-
249
- *Andrey Samsonov*
250
-
251
- * Choices of `select` can optionally contain html attributes as the last element
252
- of the child arrays when using grouped/nested collections
253
-
254
- ```erb
255
- <%= form.select :foo, [["North America", [["United States","US"],["Canada","CA"]], { disabled: "disabled" }]] %>
256
- # => <select><optgroup label="North America" disabled="disabled"><option value="US">United States</option><option value="CA">Canada</option></optgroup></select>
257
- ```
95
+ * Rename `text_area` methods into `textarea`
258
96
 
259
- *Chris Gunther*
260
-
261
- * `check_box_tag` and `radio_button_tag` now accept `checked` as a keyword argument
262
-
263
- This is to make the API more consistent with the `FormHelper` variants. You can now
264
- provide `checked` as a positional or keyword argument:
265
-
266
- ```erb
267
- = check_box_tag "admin", "1", false
268
- = check_box_tag "admin", "1", checked: false
269
-
270
- = radio_button_tag 'favorite_color', 'maroon', false
271
- = radio_button_tag 'favorite_color', 'maroon', checked: false
272
- ```
273
-
274
- *Alex Ghiculescu*
275
-
276
- * Allow passing a class to `dom_id`.
277
- You no longer need to call `new` when passing a class to `dom_id`.
278
- This makes `dom_id` behave like `dom_class` in this regard.
279
- Apart from saving a few keystrokes, it prevents Ruby from needing
280
- to instantiate a whole new object just to generate a string.
281
-
282
- Before:
283
- ```ruby
284
- dom_id(Post) # => NoMethodError: undefined method `to_key' for Post:Class
285
- ```
286
-
287
- After:
288
- ```ruby
289
- dom_id(Post) # => "new_post"
290
- ```
291
-
292
- *Goulven Champenois*
293
-
294
- * Report `:locals` as part of the data returned by ActionView render instrumentation.
295
-
296
- Before:
297
- ```ruby
298
- {
299
- identifier: "/Users/adam/projects/notifications/app/views/posts/index.html.erb",
300
- layout: "layouts/application"
301
- }
302
- ```
303
-
304
- After:
305
- ```ruby
306
- {
307
- identifier: "/Users/adam/projects/notifications/app/views/posts/index.html.erb",
308
- layout: "layouts/application",
309
- locals: {foo: "bar"}
310
- }
311
- ```
312
-
313
- *Aaron Gough*
314
-
315
- * Strip `break_sequence` at the end of `word_wrap`.
316
-
317
- This fixes a bug where `word_wrap` didn't properly strip off break sequences that had printable characters.
318
-
319
- For example, compare the outputs of this template:
320
-
321
- ```erb
322
- # <%= word_wrap("11 22\n33 44", line_width: 2, break_sequence: "\n# ") %>
323
- ```
324
-
325
- Before:
326
-
327
- ```
328
- # 11
329
- # 22
330
- #
331
- # 33
332
- # 44
333
- #
334
- ```
335
-
336
- After:
337
-
338
- ```
339
- # 11
340
- # 22
341
- # 33
342
- # 44
343
- ```
344
-
345
- *Max Chernyak*
346
-
347
- * Allow templates to set strict `locals`.
348
-
349
- By default, templates will accept any `locals` as keyword arguments. To define what `locals` a template accepts, add a `locals` magic comment:
350
-
351
- ```erb
352
- <%# locals: (message:) -%>
353
- <%= message %>
354
- ```
355
-
356
- Default values can also be provided:
357
-
358
- ```erb
359
- <%# locals: (message: "Hello, world!") -%>
360
- <%= message %>
361
- ```
362
-
363
- Or `locals` can be disabled entirely:
364
-
365
- ```erb
366
- <%# locals: () %>
367
- ```
368
-
369
- *Joel Hawksley*
370
-
371
- * Add `include_seconds` option for `datetime_local_field`
372
-
373
- This allows to omit seconds part in the input field, by passing `include_seconds: false`
374
-
375
- *Wojciech Wnętrzak*
376
-
377
- * Guard against `ActionView::Helpers::FormTagHelper#field_name` calls with nil
378
- `object_name` arguments. For example:
379
-
380
- ```erb
381
- <%= fields do |f| %>
382
- <%= f.field_name :body %>
383
- <% end %>
384
- ```
385
-
386
- *Sean Doyle*
387
-
388
- * Strings returned from `strip_tags` are correctly tagged `html_safe?`
389
-
390
- Because these strings contain no HTML elements and the basic entities are escaped, they are safe
391
- to be included as-is as PCDATA in HTML content. Tagging them as html-safe avoids double-escaping
392
- entities when being concatenated to a SafeBuffer during rendering.
393
-
394
- Fixes [rails/rails-html-sanitizer#124](https://github.com/rails/rails-html-sanitizer/issues/124)
395
-
396
- *Mike Dalessio*
397
-
398
- * Move `convert_to_model` call from `form_for` into `form_with`
399
-
400
- Now that `form_for` is implemented in terms of `form_with`, remove the
401
- `convert_to_model` call from `form_for`.
97
+ Old names are still available as aliases.
402
98
 
403
99
  *Sean Doyle*
404
100
 
405
- * Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`.
406
-
407
- Escape dangerous characters in names of tags and names of attributes in the
408
- tag helpers, following the XML specification. Rename the option
409
- `:escape_attributes` to `:escape`, to simplify by applying the option to the
410
- whole tag.
411
-
412
- *Álvaro Martín Fraguas*
101
+ * Rename `check_box*` methods into `checkbox*`.
413
102
 
414
- * Extend audio_tag and video_tag to accept Active Storage attachments.
103
+ Old names are still available as aliases.
415
104
 
416
- Now it's possible to write
417
-
418
- ```ruby
419
- audio_tag(user.audio_file)
420
- video_tag(user.video_file)
421
- ```
422
-
423
- Instead of
424
-
425
- ```ruby
426
- audio_tag(polymorphic_path(user.audio_file))
427
- video_tag(polymorphic_path(user.video_file))
428
- ```
429
-
430
- `image_tag` already supported that, so this follows the same pattern.
431
-
432
- *Matheus Richard*
433
-
434
- * Ensure models passed to `form_for` attempt to call `to_model`.
435
-
436
- *Sean Doyle*
105
+ *Jean Boussier*
437
106
 
438
- Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/actionview/CHANGELOG.md) for previous changes.
107
+ Please check [7-2-stable](https://github.com/rails/rails/blob/7-2-stable/actionview/CHANGELOG.md) for previous changes.
@@ -80,6 +80,23 @@ module ActionView # :nodoc:
80
80
  # This is useful in cases where you aren't sure if the local variable has been assigned. Alternatively, you could also use
81
81
  # <tt>defined? headline</tt> to first check if the variable has been assigned before using it.
82
82
  #
83
+ # By default, templates will accept any <tt>locals</tt> as keyword arguments. To restrict what <tt>locals</tt> a template accepts, add a <tt>locals:</tt> magic comment:
84
+ #
85
+ # <%# locals: (headline:) %>
86
+ #
87
+ # Headline: <%= headline %>
88
+ #
89
+ # In cases where the local variables are optional, declare the keyword argument with a default value:
90
+ #
91
+ # <%# locals: (headline: nil) %>
92
+ #
93
+ # <% unless headline.nil? %>
94
+ # Headline: <%= headline %>
95
+ # <% end %>
96
+ #
97
+ # Read more about strict locals in {Action View Overview}[https://guides.rubyonrails.org/action_view_overview.html#strict-locals]
98
+ # in the guides.
99
+ #
83
100
  # === Template caching
84
101
  #
85
102
  # By default, \Rails will compile each template to a method in order to render it. When you alter a template,
@@ -136,8 +153,7 @@ module ActionView # :nodoc:
136
153
  # end
137
154
  # end
138
155
  #
139
- # For more information on Builder please consult the {source
140
- # code}[https://github.com/jimweirich/builder].
156
+ # For more information on Builder please consult the {source code}[https://github.com/rails/builder].
141
157
  class Base
142
158
  include Helpers, ::ERB::Util, Context
143
159
 
@@ -249,16 +265,14 @@ module ActionView # :nodoc:
249
265
 
250
266
  if has_strict_locals
251
267
  begin
252
- public_send(method, buffer, **locals, &block)
268
+ public_send(method, locals, buffer, **locals, &block)
253
269
  rescue ArgumentError => argument_error
254
- raise(
255
- ArgumentError,
256
- argument_error.
257
- message.
258
- gsub("unknown keyword:", "unknown local:").
259
- gsub("missing keyword:", "missing local:").
260
- gsub("no keywords accepted", "no locals accepted")
261
- )
270
+ public_send_line = __LINE__ - 2
271
+ frame = argument_error.backtrace_locations[1]
272
+ if frame.path == __FILE__ && frame.lineno == public_send_line
273
+ raise StrictLocalsError.new(argument_error, @current_template)
274
+ end
275
+ raise
262
276
  end
263
277
  else
264
278
  public_send(method, locals, buffer, &block)
@@ -10,16 +10,17 @@ module ActionView
10
10
  @watcher = nil
11
11
  @previous_change = false
12
12
 
13
- rebuild_watcher
14
-
15
13
  ActionView::PathRegistry.file_system_resolver_hooks << method(:rebuild_watcher)
16
14
  end
17
15
 
18
16
  def updated?
17
+ build_watcher unless @watcher
19
18
  @previous_change || @watcher.updated?
20
19
  end
21
20
 
22
21
  def execute
22
+ return unless @watcher
23
+
23
24
  watcher = nil
24
25
  @mutex.synchronize do
25
26
  @previous_change = false
@@ -33,7 +34,7 @@ module ActionView
33
34
  ActionView::LookupContext::DetailsKey.clear
34
35
  end
35
36
 
36
- def rebuild_watcher
37
+ def build_watcher
37
38
  @mutex.synchronize do
38
39
  old_watcher = @watcher
39
40
 
@@ -51,6 +52,11 @@ module ActionView
51
52
  end
52
53
  end
53
54
 
55
+ def rebuild_watcher
56
+ return unless @watcher
57
+ build_watcher
58
+ end
59
+
54
60
  def dirs_to_watch
55
61
  all_view_paths.uniq.sort
56
62
  end