actionview 4.2.11.3 → 5.0.0.beta1
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 +5 -5
- data/CHANGELOG.md +136 -255
- data/MIT-LICENSE +1 -1
- data/README.rdoc +2 -3
- data/lib/action_view.rb +1 -1
- data/lib/action_view/base.rb +14 -2
- data/lib/action_view/dependency_tracker.rb +46 -15
- data/lib/action_view/digestor.rb +13 -9
- data/lib/action_view/flows.rb +1 -1
- data/lib/action_view/gem_version.rb +4 -4
- data/lib/action_view/helpers/asset_tag_helper.rb +15 -5
- data/lib/action_view/helpers/asset_url_helper.rb +51 -12
- data/lib/action_view/helpers/atom_feed_helper.rb +5 -4
- data/lib/action_view/helpers/cache_helper.rb +75 -20
- data/lib/action_view/helpers/capture_helper.rb +3 -2
- data/lib/action_view/helpers/controller_helper.rb +1 -0
- data/lib/action_view/helpers/date_helper.rb +39 -10
- data/lib/action_view/helpers/debug_helper.rb +1 -1
- data/lib/action_view/helpers/form_helper.rb +81 -35
- data/lib/action_view/helpers/form_options_helper.rb +74 -35
- data/lib/action_view/helpers/form_tag_helper.rb +46 -19
- data/lib/action_view/helpers/javascript_helper.rb +4 -4
- data/lib/action_view/helpers/number_helper.rb +10 -12
- data/lib/action_view/helpers/record_tag_helper.rb +12 -99
- data/lib/action_view/helpers/rendering_helper.rb +2 -2
- data/lib/action_view/helpers/sanitize_helper.rb +1 -2
- data/lib/action_view/helpers/tag_helper.rb +20 -13
- data/lib/action_view/helpers/tags/base.rb +33 -28
- data/lib/action_view/helpers/tags/collection_check_boxes.rb +2 -30
- data/lib/action_view/helpers/tags/collection_helpers.rb +28 -0
- data/lib/action_view/helpers/tags/collection_radio_buttons.rb +1 -9
- data/lib/action_view/helpers/tags/file_field.rb +15 -0
- data/lib/action_view/helpers/tags/label.rb +1 -1
- data/lib/action_view/helpers/tags/placeholderable.rb +1 -1
- data/lib/action_view/helpers/tags/search_field.rb +12 -9
- data/lib/action_view/helpers/tags/text_field.rb +0 -1
- data/lib/action_view/helpers/tags/translator.rb +1 -1
- data/lib/action_view/helpers/text_helper.rb +25 -9
- data/lib/action_view/helpers/translation_helper.rb +56 -26
- data/lib/action_view/helpers/url_helper.rb +40 -65
- data/lib/action_view/layouts.rb +11 -10
- data/lib/action_view/lookup_context.rb +14 -40
- data/lib/action_view/model_naming.rb +1 -1
- data/lib/action_view/path_set.rb +15 -18
- data/lib/action_view/railtie.rb +20 -3
- data/lib/action_view/record_identifier.rb +44 -19
- data/lib/action_view/renderer/abstract_renderer.rb +1 -1
- data/lib/action_view/renderer/partial_renderer.rb +27 -26
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +70 -0
- data/lib/action_view/renderer/renderer.rb +2 -6
- data/lib/action_view/renderer/streaming_template_renderer.rb +1 -1
- data/lib/action_view/renderer/template_renderer.rb +12 -11
- data/lib/action_view/rendering.rb +8 -5
- data/lib/action_view/routing_url_for.rb +18 -6
- data/lib/action_view/template.rb +50 -13
- data/lib/action_view/template/error.rb +14 -7
- data/lib/action_view/template/handlers.rb +3 -3
- data/lib/action_view/template/handlers/erb.rb +25 -0
- data/lib/action_view/template/handlers/raw.rb +1 -1
- data/lib/action_view/template/resolver.rb +36 -58
- data/lib/action_view/template/types.rb +1 -1
- data/lib/action_view/test_case.rb +13 -8
- data/lib/action_view/testing/resolvers.rb +3 -4
- data/lib/action_view/view_paths.rb +6 -22
- metadata +17 -14
@@ -1,10 +1,9 @@
|
|
1
1
|
require "pathname"
|
2
2
|
require "active_support/core_ext/class"
|
3
3
|
require "active_support/core_ext/module/attribute_accessors"
|
4
|
-
require 'active_support/core_ext/string/filters'
|
5
4
|
require "action_view/template"
|
6
5
|
require "thread"
|
7
|
-
require "
|
6
|
+
require "concurrent"
|
8
7
|
|
9
8
|
module ActionView
|
10
9
|
# = Action View Resolver
|
@@ -36,7 +35,7 @@ module ActionView
|
|
36
35
|
|
37
36
|
# Threadsafe template cache
|
38
37
|
class Cache #:nodoc:
|
39
|
-
class SmallCache <
|
38
|
+
class SmallCache < Concurrent::Map
|
40
39
|
def initialize(options = {})
|
41
40
|
super(options.merge(:initial_capacity => 2))
|
42
41
|
end
|
@@ -53,6 +52,7 @@ module ActionView
|
|
53
52
|
|
54
53
|
def initialize
|
55
54
|
@data = SmallCache.new(&KEY_BLOCK)
|
55
|
+
@query_cache = SmallCache.new
|
56
56
|
end
|
57
57
|
|
58
58
|
# Cache the templates returned by the block
|
@@ -71,8 +71,17 @@ module ActionView
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
+
def cache_query(query) # :nodoc:
|
75
|
+
if Resolver.caching?
|
76
|
+
@query_cache[query] ||= canonical_no_templates(yield)
|
77
|
+
else
|
78
|
+
yield
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
74
82
|
def clear
|
75
83
|
@data.clear
|
84
|
+
@query_cache.clear
|
76
85
|
end
|
77
86
|
|
78
87
|
private
|
@@ -113,14 +122,12 @@ module ActionView
|
|
113
122
|
# Normalizes the arguments and passes it on to find_templates.
|
114
123
|
def find_all(name, prefix=nil, partial=false, details={}, key=nil, locals=[])
|
115
124
|
cached(key, [name, prefix, partial], details, locals) do
|
116
|
-
find_templates(name, prefix, partial, details
|
125
|
+
find_templates(name, prefix, partial, details)
|
117
126
|
end
|
118
127
|
end
|
119
128
|
|
120
|
-
def
|
121
|
-
|
122
|
-
find_templates(name, prefix, partial, details, true)
|
123
|
-
end
|
129
|
+
def find_all_with_query(query) # :nodoc:
|
130
|
+
@cache.cache_query(query) { find_template_paths(File.join(@path, query)) }
|
124
131
|
end
|
125
132
|
|
126
133
|
private
|
@@ -130,8 +137,8 @@ module ActionView
|
|
130
137
|
# This is what child classes implement. No defaults are needed
|
131
138
|
# because Resolver guarantees that the arguments are present and
|
132
139
|
# normalized.
|
133
|
-
def find_templates(name, prefix, partial, details
|
134
|
-
raise NotImplementedError, "Subclasses must implement a find_templates(name, prefix, partial, details
|
140
|
+
def find_templates(name, prefix, partial, details)
|
141
|
+
raise NotImplementedError, "Subclasses must implement a find_templates(name, prefix, partial, details) method"
|
135
142
|
end
|
136
143
|
|
137
144
|
# Helpers that builds a path. Useful for building virtual paths.
|
@@ -145,7 +152,7 @@ module ActionView
|
|
145
152
|
# resolver is fresher before returning it.
|
146
153
|
def cached(key, path_info, details, locals) #:nodoc:
|
147
154
|
name, prefix, partial = path_info
|
148
|
-
locals = locals.map
|
155
|
+
locals = locals.map(&:to_s).sort!
|
149
156
|
|
150
157
|
if key
|
151
158
|
@cache.cache(key, name, prefix, partial, locals) do
|
@@ -180,18 +187,17 @@ module ActionView
|
|
180
187
|
|
181
188
|
private
|
182
189
|
|
183
|
-
def find_templates(name, prefix, partial, details
|
190
|
+
def find_templates(name, prefix, partial, details)
|
184
191
|
path = Path.build(name, prefix, partial)
|
185
|
-
query(path, details, details[:formats]
|
192
|
+
query(path, details, details[:formats])
|
186
193
|
end
|
187
194
|
|
188
|
-
def query(path, details, formats
|
195
|
+
def query(path, details, formats)
|
189
196
|
query = build_query(path, details)
|
190
197
|
|
191
|
-
template_paths = find_template_paths
|
192
|
-
template_paths = reject_files_external_to_app(template_paths) unless outside_app_allowed
|
198
|
+
template_paths = find_template_paths(query)
|
193
199
|
|
194
|
-
template_paths.map
|
200
|
+
template_paths.map do |template|
|
195
201
|
handler, format, variant = extract_handler_and_format_and_variant(template, formats)
|
196
202
|
contents = File.binread(template)
|
197
203
|
|
@@ -201,58 +207,36 @@ module ActionView
|
|
201
207
|
:variant => variant,
|
202
208
|
:updated_at => mtime(template)
|
203
209
|
)
|
204
|
-
}
|
205
|
-
end
|
206
|
-
|
207
|
-
def reject_files_external_to_app(files)
|
208
|
-
files.reject { |filename| !inside_path?(@path, filename) }
|
209
|
-
end
|
210
|
-
|
211
|
-
if RUBY_VERSION >= '2.2.0'
|
212
|
-
def find_template_paths(query)
|
213
|
-
Dir[query].reject { |filename|
|
214
|
-
File.directory?(filename) ||
|
215
|
-
# deals with case-insensitive file systems.
|
216
|
-
!File.fnmatch(query, filename, File::FNM_EXTGLOB)
|
217
|
-
}
|
218
|
-
end
|
219
|
-
else
|
220
|
-
def find_template_paths(query)
|
221
|
-
# deals with case-insensitive file systems.
|
222
|
-
sanitizer = Hash.new { |h,dir| h[dir] = Dir["#{dir}/*"] }
|
223
|
-
|
224
|
-
Dir[query].reject { |filename|
|
225
|
-
File.directory?(filename) ||
|
226
|
-
!sanitizer[File.dirname(filename)].include?(filename)
|
227
|
-
}
|
228
210
|
end
|
229
211
|
end
|
230
212
|
|
231
|
-
def
|
232
|
-
|
233
|
-
|
234
|
-
|
213
|
+
def find_template_paths(query)
|
214
|
+
Dir[query].reject do |filename|
|
215
|
+
File.directory?(filename) ||
|
216
|
+
# deals with case-insensitive file systems.
|
217
|
+
!File.fnmatch(query, filename, File::FNM_EXTGLOB)
|
218
|
+
end
|
235
219
|
end
|
236
220
|
|
237
221
|
# Helper for building query glob string based on resolver's pattern.
|
238
222
|
def build_query(path, details)
|
239
223
|
query = @pattern.dup
|
240
224
|
|
241
|
-
prefix = path.prefix.empty? ?
|
242
|
-
query.gsub!(
|
225
|
+
prefix = path.prefix.empty? ? '' : "#{escape_entry(path.prefix)}\\1"
|
226
|
+
query.gsub!(/:prefix(\/)?/, prefix)
|
243
227
|
|
244
228
|
partial = escape_entry(path.partial? ? "_#{path.name}" : path.name)
|
245
|
-
query.gsub!(
|
229
|
+
query.gsub!(/:action/, partial)
|
246
230
|
|
247
231
|
details.each do |ext, variants|
|
248
|
-
query.gsub!(
|
232
|
+
query.gsub!(/:#{ext}/, "{#{variants.compact.uniq.join(',')}}")
|
249
233
|
end
|
250
234
|
|
251
235
|
File.expand_path(query, @path)
|
252
236
|
end
|
253
237
|
|
254
238
|
def escape_entry(entry)
|
255
|
-
entry.gsub(/[*?{}\[\]]/, '\\\\\\&')
|
239
|
+
entry.gsub(/[*?{}\[\]]/, '\\\\\\&'.freeze)
|
256
240
|
end
|
257
241
|
|
258
242
|
# Returns the file mtime from the filesystem.
|
@@ -264,16 +248,10 @@ module ActionView
|
|
264
248
|
# from the path, or the handler, we should return the array of formats given
|
265
249
|
# to the resolver.
|
266
250
|
def extract_handler_and_format_and_variant(path, default_formats)
|
267
|
-
pieces = File.basename(path).split(
|
251
|
+
pieces = File.basename(path).split('.'.freeze)
|
268
252
|
pieces.shift
|
269
253
|
|
270
254
|
extension = pieces.pop
|
271
|
-
unless extension
|
272
|
-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
273
|
-
The file #{path} did not specify a template handler. The default is
|
274
|
-
currently ERB, but will change to RAW in the future.
|
275
|
-
MSG
|
276
|
-
end
|
277
255
|
|
278
256
|
handler = Template.handler_for_extension(extension)
|
279
257
|
format, variant = pieces.last.split(EXTENSIONS[:variants], 2) if pieces.last
|
@@ -306,7 +284,7 @@ module ActionView
|
|
306
284
|
#
|
307
285
|
# ActionController::Base.view_paths = FileSystemResolver.new(
|
308
286
|
# Rails.root.join("app/views"),
|
309
|
-
# ":prefix{
|
287
|
+
# ":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}",
|
310
288
|
# )
|
311
289
|
#
|
312
290
|
# ==== Pattern format and variables
|
@@ -24,8 +24,8 @@ module ActionView
|
|
24
24
|
def initialize
|
25
25
|
super
|
26
26
|
self.class.controller_path = ""
|
27
|
-
@request = ActionController::TestRequest.
|
28
|
-
@response =
|
27
|
+
@request = ActionController::TestRequest.create
|
28
|
+
@response = ActionDispatch::TestResponse.new
|
29
29
|
|
30
30
|
@request.env.delete('PATH_INFO')
|
31
31
|
@params = {}
|
@@ -204,7 +204,7 @@ module ActionView
|
|
204
204
|
def view
|
205
205
|
@view ||= begin
|
206
206
|
view = @controller.view_context
|
207
|
-
view.singleton_class.
|
207
|
+
view.singleton_class.include(_helpers)
|
208
208
|
view.extend(Locals)
|
209
209
|
view.rendered_views = self.rendered_views
|
210
210
|
view.output_buffer = self.output_buffer
|
@@ -241,8 +241,7 @@ module ActionView
|
|
241
241
|
:@view,
|
242
242
|
:@view_context_class,
|
243
243
|
:@_subscribers,
|
244
|
-
:@html_document
|
245
|
-
:@html_scanner_document
|
244
|
+
:@html_document
|
246
245
|
]
|
247
246
|
|
248
247
|
def _user_defined_ivars
|
@@ -264,9 +263,15 @@ module ActionView
|
|
264
263
|
end
|
265
264
|
|
266
265
|
def method_missing(selector, *args)
|
267
|
-
|
268
|
-
|
269
|
-
|
266
|
+
begin
|
267
|
+
routes = @controller.respond_to?(:_routes) && @controller._routes
|
268
|
+
rescue
|
269
|
+
# Dont call routes, if there is an error on _routes call
|
270
|
+
end
|
271
|
+
|
272
|
+
if routes &&
|
273
|
+
( routes.named_routes.route_defined?(selector) ||
|
274
|
+
routes.mounted_helpers.method_defined?(selector) )
|
270
275
|
@controller.__send__(selector, *args)
|
271
276
|
else
|
272
277
|
super
|
@@ -19,7 +19,7 @@ module ActionView #:nodoc:
|
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
|
-
def query(path, exts, formats
|
22
|
+
def query(path, exts, formats)
|
23
23
|
query = ""
|
24
24
|
EXTENSIONS.each_key do |ext|
|
25
25
|
query << '(' << exts[ext].map {|e| e && Regexp.escape(".#{e}") }.join('|') << '|)'
|
@@ -44,11 +44,10 @@ module ActionView #:nodoc:
|
|
44
44
|
end
|
45
45
|
|
46
46
|
class NullResolver < PathResolver
|
47
|
-
def query(path, exts, formats
|
47
|
+
def query(path, exts, formats)
|
48
48
|
handler, format, variant = extract_handler_and_format_and_variant(path, formats)
|
49
|
-
[ActionView::Template.new("Template generated by Null Resolver", path, handler, :virtual_path => path, :format => format, :variant => variant)]
|
49
|
+
[ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, :virtual_path => path.virtual, :format => format, :variant => variant)]
|
50
50
|
end
|
51
51
|
end
|
52
|
-
|
53
52
|
end
|
54
53
|
|
@@ -16,14 +16,9 @@ module ActionView
|
|
16
16
|
module ClassMethods
|
17
17
|
def _prefixes # :nodoc:
|
18
18
|
@_prefixes ||= begin
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
else
|
23
|
-
return local_prefixes if superclass.abstract?
|
24
|
-
|
25
|
-
local_prefixes + superclass._prefixes
|
26
|
-
end
|
19
|
+
return local_prefixes if superclass.abstract?
|
20
|
+
|
21
|
+
local_prefixes + superclass._prefixes
|
27
22
|
end
|
28
23
|
end
|
29
24
|
|
@@ -34,17 +29,6 @@ module ActionView
|
|
34
29
|
def local_prefixes
|
35
30
|
[controller_path]
|
36
31
|
end
|
37
|
-
|
38
|
-
def handle_deprecated_parent_prefixes # TODO: remove in 4.3/5.0.
|
39
|
-
return unless respond_to?(:parent_prefixes)
|
40
|
-
|
41
|
-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
42
|
-
Overriding `ActionController::Base::parent_prefixes` is deprecated,
|
43
|
-
override `.local_prefixes` instead.
|
44
|
-
MSG
|
45
|
-
|
46
|
-
local_prefixes + parent_prefixes
|
47
|
-
end
|
48
32
|
end
|
49
33
|
|
50
34
|
# The prefixes used in render "foo" shortcuts.
|
@@ -52,9 +36,9 @@ module ActionView
|
|
52
36
|
self.class._prefixes
|
53
37
|
end
|
54
38
|
|
55
|
-
# LookupContext is the object responsible
|
56
|
-
# templates, i.e. view paths and
|
57
|
-
# information.
|
39
|
+
# <tt>LookupContext</tt> is the object responsible for holding all
|
40
|
+
# information required for looking up templates, i.e. view paths and
|
41
|
+
# details. Check <tt>ActionView::LookupContext</tt> for more information.
|
58
42
|
def lookup_context
|
59
43
|
@_lookup_context ||=
|
60
44
|
ActionView::LookupContext.new(self.class._view_paths, details_for_lookup, _prefixes)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 5.0.0.beta1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 5.0.0.beta1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: builder
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,7 +61,7 @@ dependencies:
|
|
61
61
|
version: '1.0'
|
62
62
|
- - ">="
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: 1.0.
|
64
|
+
version: 1.0.2
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -71,7 +71,7 @@ dependencies:
|
|
71
71
|
version: '1.0'
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 1.0.
|
74
|
+
version: 1.0.2
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: rails-dom-testing
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,28 +98,28 @@ dependencies:
|
|
98
98
|
requirements:
|
99
99
|
- - '='
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
101
|
+
version: 5.0.0.beta1
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
106
|
- - '='
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version:
|
108
|
+
version: 5.0.0.beta1
|
109
109
|
- !ruby/object:Gem::Dependency
|
110
110
|
name: activemodel
|
111
111
|
requirement: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
113
|
- - '='
|
114
114
|
- !ruby/object:Gem::Version
|
115
|
-
version:
|
115
|
+
version: 5.0.0.beta1
|
116
116
|
type: :development
|
117
117
|
prerelease: false
|
118
118
|
version_requirements: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
120
|
- - '='
|
121
121
|
- !ruby/object:Gem::Version
|
122
|
-
version:
|
122
|
+
version: 5.0.0.beta1
|
123
123
|
description: Simple, battle-tested conventions and helpers for building web pages.
|
124
124
|
email: david@loudthinking.com
|
125
125
|
executables: []
|
@@ -207,6 +207,7 @@ files:
|
|
207
207
|
- lib/action_view/record_identifier.rb
|
208
208
|
- lib/action_view/renderer/abstract_renderer.rb
|
209
209
|
- lib/action_view/renderer/partial_renderer.rb
|
210
|
+
- lib/action_view/renderer/partial_renderer/collection_caching.rb
|
210
211
|
- lib/action_view/renderer/renderer.rb
|
211
212
|
- lib/action_view/renderer/streaming_template_renderer.rb
|
212
213
|
- lib/action_view/renderer/template_renderer.rb
|
@@ -239,16 +240,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
239
240
|
requirements:
|
240
241
|
- - ">="
|
241
242
|
- !ruby/object:Gem::Version
|
242
|
-
version:
|
243
|
+
version: 2.2.2
|
243
244
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
244
245
|
requirements:
|
245
|
-
- - "
|
246
|
+
- - ">"
|
246
247
|
- !ruby/object:Gem::Version
|
247
|
-
version:
|
248
|
+
version: 1.3.1
|
248
249
|
requirements:
|
249
250
|
- none
|
250
|
-
|
251
|
+
rubyforge_project:
|
252
|
+
rubygems_version: 2.5.1
|
251
253
|
signing_key:
|
252
254
|
specification_version: 4
|
253
255
|
summary: Rendering framework putting the V in MVC (part of Rails).
|
254
256
|
test_files: []
|
257
|
+
has_rdoc:
|