actionview 6.0.0.beta1 → 6.1.0
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 +4 -4
- data/CHANGELOG.md +206 -119
- data/MIT-LICENSE +1 -1
- data/README.rdoc +4 -2
- data/lib/action_view/base.rb +81 -15
- data/lib/action_view/cache_expiry.rb +52 -0
- data/lib/action_view/context.rb +0 -6
- data/lib/action_view/dependency_tracker.rb +10 -4
- data/lib/action_view/digestor.rb +11 -19
- data/lib/action_view/flows.rb +0 -1
- data/lib/action_view/gem_version.rb +2 -2
- data/lib/action_view/helpers/active_model_helper.rb +0 -1
- data/lib/action_view/helpers/asset_tag_helper.rb +46 -21
- data/lib/action_view/helpers/asset_url_helper.rb +6 -4
- data/lib/action_view/helpers/atom_feed_helper.rb +2 -1
- data/lib/action_view/helpers/cache_helper.rb +16 -23
- data/lib/action_view/helpers/csp_helper.rb +4 -2
- data/lib/action_view/helpers/date_helper.rb +5 -6
- data/lib/action_view/helpers/form_helper.rb +63 -21
- data/lib/action_view/helpers/form_options_helper.rb +10 -18
- data/lib/action_view/helpers/form_tag_helper.rb +12 -9
- data/lib/action_view/helpers/javascript_helper.rb +7 -5
- data/lib/action_view/helpers/number_helper.rb +9 -8
- data/lib/action_view/helpers/output_safety_helper.rb +1 -1
- data/lib/action_view/helpers/rendering_helper.rb +17 -7
- data/lib/action_view/helpers/sanitize_helper.rb +10 -16
- data/lib/action_view/helpers/tag_helper.rb +94 -19
- data/lib/action_view/helpers/tags/base.rb +10 -7
- data/lib/action_view/helpers/tags/check_box.rb +0 -1
- data/lib/action_view/helpers/tags/collection_check_boxes.rb +0 -1
- data/lib/action_view/helpers/tags/collection_helpers.rb +0 -1
- data/lib/action_view/helpers/tags/collection_radio_buttons.rb +0 -1
- data/lib/action_view/helpers/tags/color_field.rb +0 -1
- data/lib/action_view/helpers/tags/date_field.rb +1 -2
- data/lib/action_view/helpers/tags/date_select.rb +2 -3
- data/lib/action_view/helpers/tags/datetime_field.rb +0 -1
- data/lib/action_view/helpers/tags/datetime_local_field.rb +1 -2
- data/lib/action_view/helpers/tags/label.rb +4 -1
- data/lib/action_view/helpers/tags/month_field.rb +1 -2
- data/lib/action_view/helpers/tags/radio_button.rb +0 -1
- data/lib/action_view/helpers/tags/select.rb +1 -2
- data/lib/action_view/helpers/tags/text_field.rb +0 -1
- data/lib/action_view/helpers/tags/time_field.rb +1 -2
- data/lib/action_view/helpers/tags/week_field.rb +1 -2
- data/lib/action_view/helpers/text_helper.rb +1 -2
- data/lib/action_view/helpers/translation_helper.rb +99 -54
- data/lib/action_view/helpers/url_helper.rb +109 -15
- data/lib/action_view/layouts.rb +8 -10
- data/lib/action_view/log_subscriber.rb +26 -11
- data/lib/action_view/lookup_context.rb +59 -31
- data/lib/action_view/path_set.rb +3 -12
- data/lib/action_view/railtie.rb +36 -42
- data/lib/action_view/record_identifier.rb +0 -1
- data/lib/action_view/renderer/abstract_renderer.rb +142 -11
- data/lib/action_view/renderer/collection_renderer.rb +192 -0
- data/lib/action_view/renderer/object_renderer.rb +34 -0
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +35 -29
- data/lib/action_view/renderer/partial_renderer.rb +21 -273
- data/lib/action_view/renderer/renderer.rb +59 -4
- data/lib/action_view/renderer/streaming_template_renderer.rb +9 -7
- data/lib/action_view/renderer/template_renderer.rb +35 -27
- data/lib/action_view/rendering.rb +49 -29
- data/lib/action_view/routing_url_for.rb +1 -1
- data/lib/action_view/template/error.rb +30 -15
- data/lib/action_view/template/handlers/builder.rb +2 -2
- data/lib/action_view/template/handlers/erb/erubi.rb +15 -9
- data/lib/action_view/template/handlers/erb.rb +14 -19
- data/lib/action_view/template/handlers/html.rb +1 -1
- data/lib/action_view/template/handlers/raw.rb +2 -2
- data/lib/action_view/template/handlers.rb +1 -1
- data/lib/action_view/template/html.rb +5 -6
- data/lib/action_view/template/inline.rb +22 -0
- data/lib/action_view/template/raw_file.rb +25 -0
- data/lib/action_view/template/renderable.rb +24 -0
- data/lib/action_view/template/resolver.rb +141 -140
- data/lib/action_view/template/sources/file.rb +17 -0
- data/lib/action_view/template/sources.rb +13 -0
- data/lib/action_view/template/text.rb +2 -3
- data/lib/action_view/template.rb +49 -75
- data/lib/action_view/test_case.rb +20 -28
- data/lib/action_view/testing/resolvers.rb +18 -27
- data/lib/action_view/unbound_template.rb +31 -0
- data/lib/action_view/view_paths.rb +59 -38
- data/lib/action_view.rb +7 -2
- data/lib/assets/compiled/rails-ujs.js +22 -13
- metadata +30 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66b9ba4747ae5973f8f784343f64e7201d2bbf8299cb9b9dc2ed7869db55cbc6
|
4
|
+
data.tar.gz: da671bc8666ecd9386fa75a7639c837492df9b0d5b81c9f2a66114a522d6dec9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 409ff7a86026884f20e3fbf1eb0560fc990328369c15e90500f27dc8336020edc59acfb3b8da61806c7eac62ae501c1c5f176c4dc7da641f3da338bcfb2cc6f5
|
7
|
+
data.tar.gz: 961932d31d4e46c9674a9ea3229db468dfd922c1b79c9f23403b928763f1a8798848dae25554f09255965968109e7557953b4c3a7d6573e142061a3fc3e360c7
|
data/CHANGELOG.md
CHANGED
@@ -1,191 +1,278 @@
|
|
1
|
-
## Rails 6.
|
1
|
+
## Rails 6.1.0 (December 09, 2020) ##
|
2
2
|
|
3
|
-
*
|
3
|
+
* SanitizeHelper.sanitized_allowed_attributes and SanitizeHelper.sanitized_allowed_tags
|
4
|
+
call safe_list_sanitizer's class method
|
5
|
+
|
6
|
+
Fixes #39586
|
7
|
+
|
8
|
+
*Taufiq Muhammadi*
|
9
|
+
|
10
|
+
* Change form_with to generate non-remote forms by default.
|
11
|
+
|
12
|
+
`form_with` would generate a remote form by default. This would confuse
|
13
|
+
users because they were forced to handle remote requests.
|
14
|
+
|
15
|
+
All new 6.1 applications will generate non-remote forms by default.
|
16
|
+
When upgrading a 6.0 application you can enable remote forms by default by
|
17
|
+
setting `config.action_view.form_with_generates_remote_forms` to `true`.
|
18
|
+
|
19
|
+
*Petrik de Heus*
|
20
|
+
|
21
|
+
* Yield translated strings to calls of `ActionView::FormBuilder#button`
|
22
|
+
when a block is given.
|
23
|
+
|
24
|
+
*Sean Doyle*
|
25
|
+
|
26
|
+
* Alias `ActionView::Helpers::Tags::Label::LabelBuilder#translation` to
|
27
|
+
`#to_s` so that `form.label` calls can yield that value to their blocks.
|
28
|
+
|
29
|
+
*Sean Doyle*
|
30
|
+
|
31
|
+
* Rename the new `TagHelper#class_names` method to `TagHelper#token_list`,
|
32
|
+
and make the original available as an alias.
|
33
|
+
|
34
|
+
token_list("foo", "foo bar")
|
35
|
+
# => "foo bar"
|
36
|
+
|
37
|
+
*Sean Doyle*
|
38
|
+
|
39
|
+
* ARIA Array and Hash attributes are treated as space separated `DOMTokenList`
|
40
|
+
values. This is useful when declaring lists of label text identifiers in
|
41
|
+
`aria-labelledby` or `aria-describedby`.
|
42
|
+
|
43
|
+
tag.input type: 'checkbox', name: 'published', aria: {
|
44
|
+
invalid: @post.errors[:published].any?,
|
45
|
+
labelledby: ['published_context', 'published_label'],
|
46
|
+
describedby: { published_errors: @post.errors[:published].any? }
|
47
|
+
}
|
48
|
+
#=> <input
|
49
|
+
type="checkbox" name="published" aria-invalid="true"
|
50
|
+
aria-labelledby="published_context published_label"
|
51
|
+
aria-describedby="published_errors"
|
52
|
+
>
|
53
|
+
|
54
|
+
*Sean Doyle*
|
55
|
+
|
56
|
+
* Remove deprecated `escape_whitelist` from `ActionView::Template::Handlers::ERB`.
|
4
57
|
|
5
58
|
*Rafael Mendonça França*
|
6
59
|
|
7
|
-
*
|
8
|
-
`ActionView::Base` subclasses. This prevents the use of forms and buttons.
|
60
|
+
* Remove deprecated `find_all_anywhere` from `ActionView::Resolver`.
|
9
61
|
|
10
|
-
*
|
62
|
+
*Rafael Mendonça França*
|
11
63
|
|
12
|
-
*
|
13
|
-
Fixes #33889
|
64
|
+
* Remove deprecated `formats` from `ActionView::Template::HTML`.
|
14
65
|
|
15
|
-
*
|
66
|
+
*Rafael Mendonça França*
|
16
67
|
|
17
|
-
*
|
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.
|
68
|
+
* Remove deprecated `formats` from `ActionView::Template::RawFile`.
|
20
69
|
|
21
|
-
|
22
|
-
<%= link_to 'Remote', remote_path, class: 'remote', remote: true, data: { type: :json } %>
|
23
|
-
```
|
70
|
+
*Rafael Mendonça França*
|
24
71
|
|
25
|
-
|
72
|
+
* Remove deprecated `formats` from `ActionView::Template::Text`.
|
26
73
|
|
27
|
-
*
|
74
|
+
*Rafael Mendonça França*
|
28
75
|
|
29
|
-
*
|
76
|
+
* Remove deprecated `find_file` from `ActionView::PathSet`.
|
30
77
|
|
31
|
-
|
78
|
+
*Rafael Mendonça França*
|
32
79
|
|
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
|
-
```
|
80
|
+
* Remove deprecated `rendered_format` from `ActionView::LookupContext`.
|
39
81
|
|
40
|
-
|
82
|
+
*Rafael Mendonça França*
|
41
83
|
|
42
|
-
|
84
|
+
* Remove deprecated `find_file` from `ActionView::ViewPaths`.
|
43
85
|
|
44
|
-
*
|
86
|
+
*Rafael Mendonça França*
|
45
87
|
|
46
|
-
*
|
88
|
+
* Require that `ActionView::Base` subclasses implement `#compiled_method_container`.
|
47
89
|
|
48
|
-
|
90
|
+
*Rafael Mendonça França*
|
49
91
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
92
|
+
* Remove deprecated support to pass an object that is not a `ActionView::LookupContext` as the first argument
|
93
|
+
in `ActionView::Base#initialize`.
|
94
|
+
|
95
|
+
*Rafael Mendonça França*
|
96
|
+
|
97
|
+
* Remove deprecated `format` argument `ActionView::Base#initialize`.
|
98
|
+
|
99
|
+
*Rafael Mendonça França*
|
100
|
+
|
101
|
+
* Remove deprecated `ActionView::Template#refresh`.
|
102
|
+
|
103
|
+
*Rafael Mendonça França*
|
104
|
+
|
105
|
+
* Remove deprecated `ActionView::Template#original_encoding`.
|
106
|
+
|
107
|
+
*Rafael Mendonça França*
|
108
|
+
|
109
|
+
* Remove deprecated `ActionView::Template#variants`.
|
55
110
|
|
56
|
-
*
|
111
|
+
*Rafael Mendonça França*
|
57
112
|
|
58
|
-
*
|
113
|
+
* Remove deprecated `ActionView::Template#formats`.
|
59
114
|
|
60
|
-
|
115
|
+
*Rafael Mendonça França*
|
61
116
|
|
62
|
-
|
117
|
+
* Remove deprecated `ActionView::Template#virtual_path=`.
|
63
118
|
|
64
|
-
*
|
119
|
+
*Rafael Mendonça França*
|
65
120
|
|
66
|
-
|
67
|
-
and `collection_select` it is possible to call private methods from
|
68
|
-
the objects used.
|
121
|
+
* Remove deprecated `ActionView::Template#updated_at`.
|
69
122
|
|
70
|
-
|
123
|
+
*Rafael Mendonça França*
|
71
124
|
|
72
|
-
|
125
|
+
* Remove deprecated `updated_at` argument required on `ActionView::Template#initialize`.
|
73
126
|
|
74
|
-
*
|
127
|
+
*Rafael Mendonça França*
|
75
128
|
|
76
|
-
|
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.
|
129
|
+
* Make `locals` argument required on `ActionView::Template#initialize`.
|
79
130
|
|
80
|
-
|
81
|
-
`to_form_params` before comparing them.
|
131
|
+
*Rafael Mendonça França*
|
82
132
|
|
83
|
-
|
133
|
+
* Remove deprecated `ActionView::Template.finalize_compiled_template_methods`.
|
84
134
|
|
85
|
-
*
|
135
|
+
*Rafael Mendonça França*
|
86
136
|
|
87
|
-
|
137
|
+
* Remove deprecated `config.action_view.finalize_compiled_template_methods`
|
88
138
|
|
89
|
-
|
90
|
-
foo_html:
|
91
|
-
- "One"
|
92
|
-
- "<strong>Two</strong>"
|
93
|
-
- "Three 👋 🙂"
|
139
|
+
*Rafael Mendonça França*
|
94
140
|
|
95
|
-
|
141
|
+
* Remove deprecated support to calling `ActionView::ViewPaths#with_fallback` with a block.
|
96
142
|
|
97
|
-
*
|
98
|
-
names. Lambda should be passed to use this option.
|
143
|
+
*Rafael Mendonça França*
|
99
144
|
|
100
|
-
|
145
|
+
* Remove deprecated support to passing absolute paths to `render template:`.
|
101
146
|
|
102
|
-
|
147
|
+
*Rafael Mendonça França*
|
103
148
|
|
104
|
-
|
149
|
+
* Remove deprecated support to passing relative paths to `render file:`.
|
105
150
|
|
106
|
-
|
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 */
|
151
|
+
*Rafael Mendonça França*
|
112
152
|
|
113
|
-
|
153
|
+
* Remove support to template handlers that don't accept two arguments.
|
114
154
|
|
115
|
-
*
|
116
|
-
Content Security Policy.
|
155
|
+
*Rafael Mendonça França*
|
117
156
|
|
118
|
-
|
157
|
+
* Remove deprecated pattern argument in `ActionView::Template::PathResolver`.
|
119
158
|
|
120
|
-
*
|
159
|
+
*Rafael Mendonça França*
|
121
160
|
|
122
|
-
*
|
123
|
-
support automatic nonce generation for Content Security Policy.
|
124
|
-
Works the same way as `javascript_tag nonce: true` does.
|
161
|
+
* Remove deprecated support to call private methods from object in some view helpers.
|
125
162
|
|
126
|
-
*
|
163
|
+
*Rafael Mendonça França*
|
127
164
|
|
128
|
-
*
|
165
|
+
* `ActionView::Helpers::TranslationHelper#translate` accepts a block, yielding
|
166
|
+
the translated text and the fully resolved translation key:
|
129
167
|
|
130
|
-
|
168
|
+
<%= translate(".relative_key") do |translation, resolved_key| %>
|
169
|
+
<span title="<%= resolved_key %>"><%= translation %></span>
|
170
|
+
<% end %>
|
131
171
|
|
132
|
-
*
|
172
|
+
*Sean Doyle*
|
133
173
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
174
|
+
* Ensure cache fragment digests include all relevant template dependencies when
|
175
|
+
fragments are contained in a block passed to the render helper. Remove the
|
176
|
+
virtual_path keyword arguments found in CacheHelper as they no longer possess
|
177
|
+
any function following 1581cab.
|
138
178
|
|
139
|
-
|
179
|
+
Fixes #38984.
|
140
180
|
|
141
|
-
*
|
181
|
+
*Aaron Lipman*
|
142
182
|
|
143
|
-
|
183
|
+
* Deprecate `config.action_view.raise_on_missing_translations` in favor of
|
184
|
+
`config.i18n.raise_on_missing_translations`.
|
144
185
|
|
145
|
-
|
146
|
-
|
147
|
-
|
186
|
+
New generalized configuration option now determines whether an error should be raised
|
187
|
+
for missing translations in controllers and views.
|
188
|
+
|
189
|
+
*fatkodima*
|
190
|
+
|
191
|
+
* Instrument layout rendering in `TemplateRenderer#render_with_layout` as `render_layout.action_view`,
|
192
|
+
and include (when necessary) the layout's virtual path in notification payloads for collection and partial renders.
|
193
|
+
|
194
|
+
*Zach Kemp*
|
195
|
+
|
196
|
+
* `ActionView::Base.annotate_rendered_view_with_filenames` annotates HTML output with template file names.
|
197
|
+
|
198
|
+
*Joel Hawksley*, *Aaron Patterson*
|
199
|
+
|
200
|
+
* `ActionView::Helpers::TranslationHelper#translate` returns nil when
|
201
|
+
passed `default: nil` without a translation matching `I18n#translate`.
|
202
|
+
|
203
|
+
*Stefan Wrobel*
|
204
|
+
|
205
|
+
* `OptimizedFileSystemResolver` prefers template details in order of locale,
|
206
|
+
formats, variants, handlers.
|
207
|
+
|
208
|
+
*Iago Pimenta*
|
209
|
+
|
210
|
+
* Added `class_names` helper to create a CSS class value with conditional classes.
|
211
|
+
|
212
|
+
*Joel Hawksley*, *Aaron Patterson*
|
213
|
+
|
214
|
+
* Add support for conditional values to TagBuilder.
|
215
|
+
|
216
|
+
*Joel Hawksley*
|
217
|
+
|
218
|
+
* `ActionView::Helpers::FormOptionsHelper#select` should mark option for `nil` as selected.
|
219
|
+
|
220
|
+
```ruby
|
221
|
+
@post = Post.new
|
222
|
+
@post.category = nil
|
223
|
+
|
224
|
+
# Before
|
225
|
+
select("post", "category", none: nil, programming: 1, economics: 2)
|
226
|
+
# =>
|
227
|
+
# <select name="post[category]" id="post_category">
|
228
|
+
# <option value="">none</option>
|
229
|
+
# <option value="1">programming</option>
|
230
|
+
# <option value="2">economics</option>
|
231
|
+
# </select>
|
232
|
+
|
233
|
+
# After
|
234
|
+
select("post", "category", none: nil, programming: 1, economics: 2)
|
235
|
+
# =>
|
236
|
+
# <select name="post[category]" id="post_category">
|
237
|
+
# <option selected="selected" value="">none</option>
|
238
|
+
# <option value="1">programming</option>
|
239
|
+
# <option value="2">economics</option>
|
240
|
+
# </select>
|
241
|
+
```
|
242
|
+
|
243
|
+
*bogdanvlviv*
|
148
244
|
|
149
|
-
|
245
|
+
* Log lines for partial renders and started template renders are now
|
246
|
+
emitted at the `DEBUG` level instead of `INFO`.
|
150
247
|
|
151
|
-
|
152
|
-
field.
|
248
|
+
Completed template renders are still logged at the `INFO` level.
|
153
249
|
|
154
|
-
|
250
|
+
*DHH*
|
155
251
|
|
156
|
-
|
157
|
-
:category,
|
158
|
-
["lifestyle", "programming", "spiritual"],
|
159
|
-
{ selected: "", disabled: "", prompt: "Choose one" },
|
160
|
-
{ required: true }
|
252
|
+
* ActionView::Helpers::SanitizeHelper: support rails-html-sanitizer 1.1.0.
|
161
253
|
|
162
|
-
|
254
|
+
*Juanito Fatas*
|
163
255
|
|
164
|
-
|
256
|
+
* Added `phone_to` helper method to create a link from mobile numbers.
|
165
257
|
|
166
|
-
|
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>
|
258
|
+
*Pietro Moro*
|
171
259
|
|
172
|
-
|
260
|
+
* annotated_source_code returns an empty array so TemplateErrors without a
|
261
|
+
template in the backtrace are surfaced properly by DebugExceptions.
|
173
262
|
|
174
|
-
*
|
263
|
+
*Guilherme Mansur*, *Kasper Timm Hansen*
|
175
264
|
|
176
|
-
|
177
|
-
IE8 or lower becomes increasingly difficult so default to not enforcing
|
178
|
-
UTF-8 encoding as it's not relevant to other browsers.
|
265
|
+
* Add autoload for SyntaxErrorInTemplate so syntax errors are correctly raised by DebugExceptions.
|
179
266
|
|
180
|
-
*
|
267
|
+
*Guilherme Mansur*, *Gannon McGibbon*
|
181
268
|
|
182
|
-
*
|
269
|
+
* `RenderingHelper` supports rendering objects that `respond_to?` `:render_in`.
|
183
270
|
|
184
|
-
*
|
271
|
+
*Joel Hawksley*, *Natasha Umer*, *Aaron Patterson*, *Shawn Allen*, *Emily Plummer*, *Diana Mounter*, *John Hawthorn*, *Nathan Herald*, *Zaid Zawaideh*, *Zach Ahn*
|
185
272
|
|
186
|
-
*
|
273
|
+
* Fix `select_tag` so that it doesn't change `options` when `include_blank` is present.
|
187
274
|
|
188
|
-
*
|
275
|
+
*Younes SERRAJ*
|
189
276
|
|
190
277
|
|
191
|
-
Please check [
|
278
|
+
Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/actionview/CHANGELOG.md) for previous changes.
|
data/MIT-LICENSE
CHANGED
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:
|
@@ -27,7 +29,7 @@ Action View is released under the MIT license:
|
|
27
29
|
|
28
30
|
API documentation is at
|
29
31
|
|
30
|
-
*
|
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://
|
40
|
+
* https://discuss.rubyonrails.org/c/rubyonrails-core
|
data/lib/action_view/base.rb
CHANGED
@@ -27,7 +27,7 @@ module ActionView #:nodoc:
|
|
27
27
|
# Name: <%= person.name %><br/>
|
28
28
|
# <% end %>
|
29
29
|
#
|
30
|
-
# The loop is
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
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_template = @output_buffer, @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, @current_template = _old_output_buffer, _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
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActionView
|
4
|
+
class CacheExpiry
|
5
|
+
class Executor
|
6
|
+
def initialize(watcher:)
|
7
|
+
@cache_expiry = CacheExpiry.new(watcher: watcher)
|
8
|
+
end
|
9
|
+
|
10
|
+
def before(target)
|
11
|
+
@cache_expiry.clear_cache_if_necessary
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(watcher:)
|
16
|
+
@watched_dirs = nil
|
17
|
+
@watcher_class = watcher
|
18
|
+
@watcher = nil
|
19
|
+
@mutex = Mutex.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def clear_cache_if_necessary
|
23
|
+
@mutex.synchronize do
|
24
|
+
watched_dirs = dirs_to_watch
|
25
|
+
return if watched_dirs.empty?
|
26
|
+
|
27
|
+
if watched_dirs != @watched_dirs
|
28
|
+
@watched_dirs = watched_dirs
|
29
|
+
@watcher = @watcher_class.new([], watched_dirs) do
|
30
|
+
clear_cache
|
31
|
+
end
|
32
|
+
@watcher.execute
|
33
|
+
else
|
34
|
+
@watcher.execute_if_updated
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def clear_cache
|
40
|
+
ActionView::LookupContext::DetailsKey.clear
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
def dirs_to_watch
|
45
|
+
all_view_paths.grep(FileSystemResolver).map!(&:path).tap(&:uniq!).sort!
|
46
|
+
end
|
47
|
+
|
48
|
+
def all_view_paths
|
49
|
+
ActionView::ViewPaths.all_view_paths.flat_map(&:paths)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/action_view/context.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActionView
|
4
|
-
module CompiledTemplates #:nodoc:
|
5
|
-
# holds compiled template code
|
6
|
-
end
|
7
|
-
|
8
4
|
# = Action View Context
|
9
5
|
#
|
10
6
|
# Action View contexts are supplied to Action Controller to render a template.
|
@@ -16,14 +12,12 @@ module ActionView
|
|
16
12
|
# object that includes this module (although you can call _prepare_context
|
17
13
|
# defined below).
|
18
14
|
module Context
|
19
|
-
include CompiledTemplates
|
20
15
|
attr_accessor :output_buffer, :view_flow
|
21
16
|
|
22
17
|
# Prepares the context by setting the appropriate instance variables.
|
23
18
|
def _prepare_context
|
24
19
|
@view_flow = OutputFlow.new
|
25
20
|
@output_buffer = nil
|
26
|
-
@virtual_path = nil
|
27
21
|
end
|
28
22
|
|
29
23
|
# Encapsulates the interaction with the view flow so it
|