actionview 5.2.4.rc1 → 6.0.0.rc2
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 +182 -77
- data/MIT-LICENSE +1 -1
- data/README.rdoc +4 -2
- data/lib/action_view.rb +3 -2
- data/lib/action_view/base.rb +107 -10
- data/lib/action_view/buffers.rb +15 -0
- data/lib/action_view/cache_expiry.rb +54 -0
- data/lib/action_view/context.rb +5 -9
- data/lib/action_view/digestor.rb +8 -17
- data/lib/action_view/gem_version.rb +4 -4
- data/lib/action_view/helpers.rb +0 -2
- data/lib/action_view/helpers/asset_tag_helper.rb +7 -30
- data/lib/action_view/helpers/asset_url_helper.rb +4 -3
- data/lib/action_view/helpers/cache_helper.rb +18 -10
- data/lib/action_view/helpers/capture_helper.rb +4 -0
- data/lib/action_view/helpers/csp_helper.rb +4 -2
- data/lib/action_view/helpers/csrf_helper.rb +1 -1
- data/lib/action_view/helpers/date_helper.rb +69 -25
- data/lib/action_view/helpers/form_helper.rb +238 -6
- data/lib/action_view/helpers/form_options_helper.rb +23 -15
- data/lib/action_view/helpers/form_tag_helper.rb +12 -11
- data/lib/action_view/helpers/javascript_helper.rb +9 -8
- data/lib/action_view/helpers/number_helper.rb +5 -0
- data/lib/action_view/helpers/output_safety_helper.rb +1 -1
- data/lib/action_view/helpers/rendering_helper.rb +6 -4
- data/lib/action_view/helpers/sanitize_helper.rb +3 -3
- data/lib/action_view/helpers/tag_helper.rb +7 -6
- data/lib/action_view/helpers/tags/base.rb +9 -5
- data/lib/action_view/helpers/tags/color_field.rb +1 -1
- data/lib/action_view/helpers/tags/translator.rb +1 -6
- data/lib/action_view/helpers/text_helper.rb +3 -3
- data/lib/action_view/helpers/translation_helper.rb +16 -12
- data/lib/action_view/helpers/url_helper.rb +14 -14
- data/lib/action_view/layouts.rb +5 -5
- data/lib/action_view/log_subscriber.rb +6 -6
- data/lib/action_view/lookup_context.rb +73 -31
- data/lib/action_view/path_set.rb +5 -10
- data/lib/action_view/railtie.rb +24 -1
- data/lib/action_view/record_identifier.rb +2 -2
- data/lib/action_view/renderer/abstract_renderer.rb +56 -3
- data/lib/action_view/renderer/partial_renderer.rb +66 -52
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +62 -16
- data/lib/action_view/renderer/renderer.rb +16 -4
- data/lib/action_view/renderer/streaming_template_renderer.rb +5 -5
- data/lib/action_view/renderer/template_renderer.rb +24 -18
- data/lib/action_view/rendering.rb +51 -31
- data/lib/action_view/routing_url_for.rb +12 -11
- data/lib/action_view/template.rb +102 -70
- data/lib/action_view/template/error.rb +21 -1
- data/lib/action_view/template/handlers.rb +27 -1
- data/lib/action_view/template/handlers/builder.rb +2 -2
- data/lib/action_view/template/handlers/erb.rb +17 -7
- data/lib/action_view/template/handlers/erb/erubi.rb +7 -3
- 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/html.rb +14 -5
- data/lib/action_view/template/inline.rb +22 -0
- data/lib/action_view/template/raw_file.rb +28 -0
- data/lib/action_view/template/resolver.rb +136 -133
- data/lib/action_view/template/sources.rb +13 -0
- data/lib/action_view/template/sources/file.rb +17 -0
- data/lib/action_view/template/text.rb +5 -3
- data/lib/action_view/test_case.rb +1 -1
- data/lib/action_view/testing/resolvers.rb +12 -11
- data/lib/action_view/unbound_template.rb +32 -0
- data/lib/action_view/view_paths.rb +25 -1
- data/lib/assets/compiled/rails-ujs.js +27 -4
- metadata +19 -14
- data/lib/action_view/helpers/record_tag_helper.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 406c498360f8019bff664abb10c1607a5e9c7fff833fdf435558fe3d75aeb472
|
4
|
+
data.tar.gz: 590891edac2051e98a8c0428071b63882e62d493f5a5a7d12d938f9b8c51bd4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6cc2b63b31fdc302fd9c4b8014e7133578995f815fe00e1d082b6bf662cade34c363162e5a72fae2b7299ac70dc4e093b43c4eac43165e61258d067131d6e98
|
7
|
+
data.tar.gz: 5ee50935ad12820bf14bed3a6e86521cae20a255746cd01c8770f27cff4c011081cc53a1476760d2817b59dc11b6a47cfa7f2c490ba5769ef46bf82620f5fcf3
|
data/CHANGELOG.md
CHANGED
@@ -1,27 +1,37 @@
|
|
1
|
-
## Rails
|
1
|
+
## Rails 6.0.0.rc2 (July 22, 2019) ##
|
2
2
|
|
3
|
-
*
|
4
|
-
Programmatic click events (eg. ones generated by `Rails.fire(link, "click")`) don't specify a button. These events were being incorrectly stopped by code meant to ignore scroll wheel and right clicks introduced in #34573.
|
3
|
+
* Fix `select_tag` so that it doesn't change `options` when `include_blank` is present.
|
5
4
|
|
6
|
-
*
|
5
|
+
*Younes SERRAJ*
|
7
6
|
|
8
7
|
|
9
|
-
## Rails
|
8
|
+
## Rails 6.0.0.rc1 (April 24, 2019) ##
|
10
9
|
|
11
|
-
*
|
12
|
-
Firefox fires click events even if the click was triggered by non-primary mouse keys such as right- or scroll-wheel-clicks.
|
13
|
-
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.
|
10
|
+
* Fix partial caching skips same item issue
|
14
11
|
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
If we render cached collection partials with repeated items, those repeated items
|
13
|
+
will get skipped. For example, if you have 5 identical items in your collection, Rails
|
14
|
+
only renders the first one when `cached` is set to true. But it should render all
|
15
|
+
5 items instead.
|
18
16
|
|
19
|
-
Fixes #
|
17
|
+
Fixes #35114.
|
20
18
|
|
21
|
-
*
|
19
|
+
*Stan Lo*
|
20
|
+
|
21
|
+
* Only clear ActionView cache in development on file changes
|
22
|
+
|
23
|
+
To speed up development mode, view caches are only cleared when files in
|
24
|
+
the view paths have changed. Applications which have implemented custom
|
25
|
+
`ActionView::Resolver` subclasses may need to add their own cache clearing.
|
26
|
+
|
27
|
+
*John Hawthorn*
|
22
28
|
|
29
|
+
* Fix `ActionView::FixtureResolver` so that it handles template variants correctly.
|
23
30
|
|
24
|
-
|
31
|
+
*Edward Rudd*
|
32
|
+
|
33
|
+
|
34
|
+
## Rails 6.0.0.beta3 (March 11, 2019) ##
|
25
35
|
|
26
36
|
* Only accept formats from registered mime types
|
27
37
|
|
@@ -35,22 +45,104 @@
|
|
35
45
|
*John Hawthorn*, *Eileen M. Uchitelle*, *Aaron Patterson*
|
36
46
|
|
37
47
|
|
38
|
-
## Rails
|
48
|
+
## Rails 6.0.0.beta2 (February 25, 2019) ##
|
49
|
+
|
50
|
+
* `ActionView::Template.finalize_compiled_template_methods` is deprecated with
|
51
|
+
no replacement.
|
52
|
+
|
53
|
+
*tenderlove*
|
54
|
+
|
55
|
+
* `config.action_view.finalize_compiled_template_methods` is deprecated with
|
56
|
+
no replacement.
|
57
|
+
|
58
|
+
*tenderlove*
|
59
|
+
|
60
|
+
* Ensure unique DOM IDs for collection inputs with float values.
|
61
|
+
|
62
|
+
Fixes #34974.
|
63
|
+
|
64
|
+
*Mark Edmondson*
|
65
|
+
|
39
66
|
|
40
|
-
|
67
|
+
## Rails 6.0.0.beta1 (January 18, 2019) ##
|
41
68
|
|
69
|
+
* [Rename npm package](https://github.com/rails/rails/pull/34905) from
|
70
|
+
[`rails-ujs`](https://www.npmjs.com/package/rails-ujs) to
|
71
|
+
[`@rails/ujs`](https://www.npmjs.com/package/@rails/ujs).
|
42
72
|
|
43
|
-
|
73
|
+
*Javan Makhmali*
|
44
74
|
|
45
|
-
*
|
75
|
+
* Remove deprecated `image_alt` helper.
|
46
76
|
|
77
|
+
*Rafael Mendonça França*
|
78
|
+
|
79
|
+
* Fix the need of `#protect_against_forgery?` method defined in
|
80
|
+
`ActionView::Base` subclasses. This prevents the use of forms and buttons.
|
81
|
+
|
82
|
+
*Genadi Samokovarov*
|
83
|
+
|
84
|
+
* Fix UJS permanently showing disabled text in a[data-remote][data-disable-with] elements within forms.
|
85
|
+
|
86
|
+
Fixes #33889.
|
87
|
+
|
88
|
+
*Wolfgang Hobmaier*
|
89
|
+
|
90
|
+
* Prevent non-primary mouse keys from triggering Rails UJS click handlers.
|
91
|
+
Firefox fires click events even if the click was triggered by non-primary mouse keys such as right- or scroll-wheel-clicks.
|
92
|
+
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.
|
93
|
+
|
94
|
+
```
|
95
|
+
<%= link_to 'Remote', remote_path, class: 'remote', remote: true, data: { type: :json } %>
|
96
|
+
```
|
47
97
|
|
48
|
-
|
98
|
+
Fixes #34541.
|
49
99
|
|
50
|
-
*
|
51
|
-
|
100
|
+
*Wolfgang Hobmaier*
|
101
|
+
|
102
|
+
* Prevent `ActionView::TextHelper#word_wrap` from unexpectedly stripping white space from the _left_ side of lines.
|
103
|
+
|
104
|
+
For example, given input like this:
|
52
105
|
|
53
|
-
|
106
|
+
```
|
107
|
+
This is a paragraph with an initial indent,
|
108
|
+
followed by additional lines that are not indented,
|
109
|
+
and finally terminated with a blockquote:
|
110
|
+
"A pithy saying"
|
111
|
+
```
|
112
|
+
|
113
|
+
Calling `word_wrap` should not trim the indents on the first and last lines.
|
114
|
+
|
115
|
+
Fixes #34487.
|
116
|
+
|
117
|
+
*Lyle Mullican*
|
118
|
+
|
119
|
+
* Add allocations to template rendering instrumentation.
|
120
|
+
|
121
|
+
Adds the allocations for template and partial rendering to the server output on render.
|
122
|
+
|
123
|
+
```
|
124
|
+
Rendered posts/_form.html.erb (Duration: 7.1ms | Allocations: 6004)
|
125
|
+
Rendered posts/new.html.erb within layouts/application (Duration: 8.3ms | Allocations: 6654)
|
126
|
+
Completed 200 OK in 858ms (Views: 848.4ms | ActiveRecord: 0.4ms | Allocations: 1539564)
|
127
|
+
```
|
128
|
+
|
129
|
+
*Eileen M. Uchitelle*, *Aaron Patterson*
|
130
|
+
|
131
|
+
* Respect the `only_path` option passed to `url_for` when the options are passed in as an array
|
132
|
+
|
133
|
+
Fixes #33237.
|
134
|
+
|
135
|
+
*Joel Ambass*
|
136
|
+
|
137
|
+
* Deprecate calling private model methods from view helpers.
|
138
|
+
|
139
|
+
For example, in methods like `options_from_collection_for_select`
|
140
|
+
and `collection_select` it is possible to call private methods from
|
141
|
+
the objects used.
|
142
|
+
|
143
|
+
Fixes #33546.
|
144
|
+
|
145
|
+
*Ana María Martínez Gómez*
|
54
146
|
|
55
147
|
* Fix issue with `button_to`'s `to_form_params`
|
56
148
|
|
@@ -63,97 +155,110 @@
|
|
63
155
|
|
64
156
|
*Georgi Georgiev*
|
65
157
|
|
66
|
-
*
|
67
|
-
Content Security Policy.
|
158
|
+
* Mark arrays of translations as trusted safe by using the `_html` suffix.
|
68
159
|
|
69
|
-
|
160
|
+
Example:
|
70
161
|
|
71
|
-
|
162
|
+
en:
|
163
|
+
foo_html:
|
164
|
+
- "One"
|
165
|
+
- "<strong>Two</strong>"
|
166
|
+
- "Three 👋 🙂"
|
72
167
|
|
73
|
-
*
|
74
|
-
support automatic nonce generation for Content Security Policy.
|
75
|
-
Works the same way as `javascript_tag nonce: true` does.
|
76
|
-
|
77
|
-
*Yaroslav Markin*
|
168
|
+
*Juan Broullon*
|
78
169
|
|
170
|
+
* Add `year_format` option to date_select tag. This option makes it possible to customize year
|
171
|
+
names. Lambda should be passed to use this option.
|
79
172
|
|
80
|
-
|
173
|
+
Example:
|
81
174
|
|
82
|
-
|
175
|
+
date_select('user_birthday', '', start_year: 1998, end_year: 2000, year_format: ->year { "Heisei #{year - 1988}" })
|
83
176
|
|
84
|
-
|
177
|
+
The HTML produced:
|
85
178
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
it is now able to receive procs and other callable objects too.
|
179
|
+
<select id="user_birthday__1i" name="user_birthday[(1i)]">
|
180
|
+
<option value="1998">Heisei 10</option>
|
181
|
+
<option value="1999">Heisei 11</option>
|
182
|
+
<option value="2000">Heisei 12</option>
|
183
|
+
</select>
|
184
|
+
/* The rest is omitted */
|
93
185
|
|
94
|
-
*
|
186
|
+
*Koki Ryu*
|
95
187
|
|
96
|
-
*
|
188
|
+
* Fix JavaScript views rendering does not work with Firefox when using
|
189
|
+
Content Security Policy.
|
97
190
|
|
98
|
-
|
99
|
-
(different to the specified in `javascript_include_tag` and `stylesheet_link_tag`).
|
100
|
-
Additionally, this sends Early Hints if supported by browser.
|
191
|
+
Fixes #32577.
|
101
192
|
|
102
|
-
*
|
193
|
+
*Yuji Yaginuma*
|
103
194
|
|
104
|
-
*
|
195
|
+
* Add the `nonce: true` option for `javascript_include_tag` helper to
|
196
|
+
support automatic nonce generation for Content Security Policy.
|
197
|
+
Works the same way as `javascript_tag nonce: true` does.
|
105
198
|
|
106
|
-
|
107
|
-
that was enabled in `form_for`. This usually is not an good idea since labels don't work
|
108
|
-
when the input doesn't have an id and it made harder to test with Capybara.
|
199
|
+
*Yaroslav Markin*
|
109
200
|
|
110
|
-
|
111
|
-
to `false.`
|
201
|
+
* Remove `ActionView::Helpers::RecordTagHelper`.
|
112
202
|
|
113
|
-
*
|
203
|
+
*Yoshiyuki Hirano*
|
114
204
|
|
115
|
-
*
|
205
|
+
* Disable `ActionView::Template` finalizers in test environment.
|
116
206
|
|
117
|
-
|
207
|
+
Template finalization can be expensive in large view test suites.
|
208
|
+
Add a configuration option,
|
209
|
+
`action_view.finalize_compiled_template_methods`, and turn it off in
|
210
|
+
the test environment.
|
118
211
|
|
119
|
-
*
|
212
|
+
*Simon Coffey*
|
120
213
|
|
121
|
-
*
|
214
|
+
* Extract the `confirm` call in its own, overridable method in `rails_ujs`.
|
122
215
|
|
123
|
-
|
216
|
+
Example:
|
124
217
|
|
125
|
-
|
218
|
+
Rails.confirm = function(message, element) {
|
219
|
+
return (my_bootstrap_modal_confirm(message));
|
220
|
+
}
|
126
221
|
|
127
|
-
|
222
|
+
*Mathieu Mahé*
|
128
223
|
|
129
|
-
|
224
|
+
* Enable select tag helper to mark `prompt` option as `selected` and/or `disabled` for `required`
|
225
|
+
field.
|
130
226
|
|
131
|
-
|
227
|
+
Example:
|
132
228
|
|
133
|
-
|
229
|
+
select :post,
|
230
|
+
:category,
|
231
|
+
["lifestyle", "programming", "spiritual"],
|
232
|
+
{ selected: "", disabled: "", prompt: "Choose one" },
|
233
|
+
{ required: true }
|
134
234
|
|
135
|
-
|
235
|
+
Placeholder option would be selected and disabled.
|
136
236
|
|
137
|
-
|
237
|
+
The HTML produced:
|
138
238
|
|
139
|
-
|
239
|
+
<select required="required" name="post[category]" id="post_category">
|
240
|
+
<option disabled="disabled" selected="selected" value="">Choose one</option>
|
241
|
+
<option value="lifestyle">lifestyle</option>
|
242
|
+
<option value="programming">programming</option>
|
243
|
+
<option value="spiritual">spiritual</option></select>
|
140
244
|
|
141
|
-
*
|
245
|
+
*Sergey Prikhodko*
|
142
246
|
|
143
|
-
|
247
|
+
* Don't enforce UTF-8 by default.
|
144
248
|
|
145
|
-
|
249
|
+
With the disabling of TLS 1.0 by most major websites, continuing to run
|
250
|
+
IE8 or lower becomes increasingly difficult so default to not enforcing
|
251
|
+
UTF-8 encoding as it's not relevant to other browsers.
|
146
252
|
|
147
|
-
*
|
253
|
+
*Andrew White*
|
148
254
|
|
149
|
-
*
|
255
|
+
* Change translation key of `submit_tag` from `module_name_class_name` to `module_name/class_name`.
|
150
256
|
|
151
|
-
*
|
257
|
+
*Rui Onodera*
|
152
258
|
|
153
|
-
*
|
154
|
-
for bad input.
|
259
|
+
* Rails 6 requires Ruby 2.5.0 or newer.
|
155
260
|
|
156
|
-
*
|
261
|
+
*Jeremy Daer*, *Kasper Timm Hansen*
|
157
262
|
|
158
263
|
|
159
|
-
Please check [5-
|
264
|
+
Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-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:
|
@@ -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/
|
18
|
+
* https://github.com/rails/rails/tree/master/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
|
-
*
|
32
|
+
* https://api.rubyonrails.org
|
31
33
|
|
32
34
|
Bug reports for the Ruby on Rails project can be filed here:
|
33
35
|
|
data/lib/action_view.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright (c) 2004-
|
4
|
+
# Copyright (c) 2004-2019 David Heinemeier Hansson
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining
|
7
7
|
# a copy of this software and associated documentation files (the
|
@@ -35,7 +35,6 @@ module ActionView
|
|
35
35
|
eager_autoload do
|
36
36
|
autoload :Base
|
37
37
|
autoload :Context
|
38
|
-
autoload :CompiledTemplates, "action_view/context"
|
39
38
|
autoload :Digestor
|
40
39
|
autoload :Helpers
|
41
40
|
autoload :LookupContext
|
@@ -45,6 +44,7 @@ module ActionView
|
|
45
44
|
autoload :Rendering
|
46
45
|
autoload :RoutingUrlFor
|
47
46
|
autoload :Template
|
47
|
+
autoload :UnboundTemplate
|
48
48
|
autoload :ViewPaths
|
49
49
|
|
50
50
|
autoload_under "renderer" do
|
@@ -81,6 +81,7 @@ module ActionView
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
+
autoload :CacheExpiry
|
84
85
|
autoload :TestCase
|
85
86
|
|
86
87
|
def self.eager_load!
|
data/lib/action_view/base.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require "active_support/core_ext/module/attr_internal"
|
4
4
|
require "active_support/core_ext/module/attribute_accessors"
|
5
5
|
require "active_support/ordered_options"
|
6
|
+
require "active_support/deprecation"
|
6
7
|
require "action_view/log_subscriber"
|
7
8
|
require "action_view/helpers"
|
8
9
|
require "action_view/context"
|
@@ -179,37 +180,133 @@ module ActionView #:nodoc:
|
|
179
180
|
def xss_safe? #:nodoc:
|
180
181
|
true
|
181
182
|
end
|
183
|
+
|
184
|
+
def with_empty_template_cache # :nodoc:
|
185
|
+
subclass = Class.new(self) {
|
186
|
+
# We can't implement these as self.class because subclasses will
|
187
|
+
# share the same template cache as superclasses, so "changed?" won't work
|
188
|
+
# correctly.
|
189
|
+
define_method(:compiled_method_container) { subclass }
|
190
|
+
define_singleton_method(:compiled_method_container) { subclass }
|
191
|
+
}
|
192
|
+
end
|
193
|
+
|
194
|
+
def changed?(other) # :nodoc:
|
195
|
+
compiled_method_container != other.compiled_method_container
|
196
|
+
end
|
182
197
|
end
|
183
198
|
|
184
|
-
|
199
|
+
attr_reader :view_renderer, :lookup_context
|
185
200
|
attr_internal :config, :assigns
|
186
201
|
|
187
|
-
delegate :lookup_context, to: :view_renderer
|
188
202
|
delegate :formats, :formats=, :locale, :locale=, :view_paths, :view_paths=, to: :lookup_context
|
189
203
|
|
190
204
|
def assign(new_assigns) # :nodoc:
|
191
205
|
@_assigns = new_assigns.each { |key, value| instance_variable_set("@#{key}", value) }
|
192
206
|
end
|
193
207
|
|
194
|
-
|
208
|
+
# :stopdoc:
|
209
|
+
|
210
|
+
def self.build_lookup_context(context)
|
211
|
+
case context
|
212
|
+
when ActionView::Renderer
|
213
|
+
context.lookup_context
|
214
|
+
when Array
|
215
|
+
ActionView::LookupContext.new(context)
|
216
|
+
when ActionView::PathSet
|
217
|
+
ActionView::LookupContext.new(context)
|
218
|
+
when nil
|
219
|
+
ActionView::LookupContext.new([])
|
220
|
+
else
|
221
|
+
raise NotImplementedError, context.class.name
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
def self.empty
|
226
|
+
with_view_paths([])
|
227
|
+
end
|
228
|
+
|
229
|
+
def self.with_view_paths(view_paths, assigns = {}, controller = nil)
|
230
|
+
with_context ActionView::LookupContext.new(view_paths), assigns, controller
|
231
|
+
end
|
232
|
+
|
233
|
+
def self.with_context(context, assigns = {}, controller = nil)
|
234
|
+
new context, assigns, controller
|
235
|
+
end
|
236
|
+
|
237
|
+
NULL = Object.new
|
238
|
+
|
239
|
+
# :startdoc:
|
240
|
+
|
241
|
+
def initialize(lookup_context = nil, assigns = {}, controller = nil, formats = NULL) #:nodoc:
|
195
242
|
@_config = ActiveSupport::InheritableOptions.new
|
196
243
|
|
197
|
-
|
198
|
-
|
244
|
+
unless formats == NULL
|
245
|
+
ActiveSupport::Deprecation.warn <<~eowarn.squish
|
246
|
+
Passing formats to ActionView::Base.new is deprecated
|
247
|
+
eowarn
|
248
|
+
end
|
249
|
+
|
250
|
+
case lookup_context
|
251
|
+
when ActionView::LookupContext
|
252
|
+
@lookup_context = lookup_context
|
199
253
|
else
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
@
|
254
|
+
ActiveSupport::Deprecation.warn <<~eowarn.squish
|
255
|
+
ActionView::Base instances should be constructed with a lookup context,
|
256
|
+
assignments, and a controller.
|
257
|
+
eowarn
|
258
|
+
@lookup_context = self.class.build_lookup_context(lookup_context)
|
205
259
|
end
|
206
260
|
|
261
|
+
@view_renderer = ActionView::Renderer.new @lookup_context
|
262
|
+
@current_template = nil
|
263
|
+
|
207
264
|
@cache_hit = {}
|
208
265
|
assign(assigns)
|
209
266
|
assign_controller(controller)
|
210
267
|
_prepare_context
|
211
268
|
end
|
212
269
|
|
270
|
+
def _run(method, template, locals, buffer, &block)
|
271
|
+
_old_output_buffer, _old_virtual_path, _old_template = @output_buffer, @virtual_path, @current_template
|
272
|
+
@current_template = template
|
273
|
+
@output_buffer = buffer
|
274
|
+
send(method, locals, buffer, &block)
|
275
|
+
ensure
|
276
|
+
@output_buffer, @virtual_path, @current_template = _old_output_buffer, _old_virtual_path, _old_template
|
277
|
+
end
|
278
|
+
|
279
|
+
def compiled_method_container
|
280
|
+
if self.class == ActionView::Base
|
281
|
+
ActiveSupport::Deprecation.warn <<~eowarn.squish
|
282
|
+
ActionView::Base instances must implement `compiled_method_container`
|
283
|
+
or use the class method `with_empty_template_cache` for constructing
|
284
|
+
an ActionView::Base instances that has an empty cache.
|
285
|
+
eowarn
|
286
|
+
end
|
287
|
+
|
288
|
+
self.class
|
289
|
+
end
|
290
|
+
|
291
|
+
def in_rendering_context(options)
|
292
|
+
old_view_renderer = @view_renderer
|
293
|
+
old_lookup_context = @lookup_context
|
294
|
+
|
295
|
+
if !lookup_context.html_fallback_for_js && options[:formats]
|
296
|
+
formats = Array(options[:formats])
|
297
|
+
if formats == [:js]
|
298
|
+
formats << :html
|
299
|
+
end
|
300
|
+
@lookup_context = lookup_context.with_prepended_formats(formats)
|
301
|
+
@view_renderer = ActionView::Renderer.new @lookup_context
|
302
|
+
end
|
303
|
+
|
304
|
+
yield @view_renderer
|
305
|
+
ensure
|
306
|
+
@view_renderer = old_view_renderer
|
307
|
+
@lookup_context = old_lookup_context
|
308
|
+
end
|
309
|
+
|
213
310
|
ActiveSupport.run_load_hooks(:action_view, self)
|
214
311
|
end
|
215
312
|
end
|