actionview 4.1.13 → 6.1.3.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionview might be problematic. Click here for more details.

Files changed (124) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +181 -359
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +12 -6
  5. data/lib/action_view/base.rb +115 -43
  6. data/lib/action_view/buffers.rb +22 -4
  7. data/lib/action_view/cache_expiry.rb +52 -0
  8. data/lib/action_view/context.rb +8 -12
  9. data/lib/action_view/dependency_tracker.rb +61 -21
  10. data/lib/action_view/digestor.rb +89 -84
  11. data/lib/action_view/flows.rb +12 -13
  12. data/lib/action_view/gem_version.rb +6 -4
  13. data/lib/action_view/helpers/active_model_helper.rb +16 -11
  14. data/lib/action_view/helpers/asset_tag_helper.rb +311 -105
  15. data/lib/action_view/helpers/asset_url_helper.rb +197 -80
  16. data/lib/action_view/helpers/atom_feed_helper.rb +20 -17
  17. data/lib/action_view/helpers/cache_helper.rb +109 -45
  18. data/lib/action_view/helpers/capture_helper.rb +20 -22
  19. data/lib/action_view/helpers/controller_helper.rb +15 -4
  20. data/lib/action_view/helpers/csp_helper.rb +26 -0
  21. data/lib/action_view/helpers/csrf_helper.rb +8 -6
  22. data/lib/action_view/helpers/date_helper.rb +245 -140
  23. data/lib/action_view/helpers/debug_helper.rb +14 -17
  24. data/lib/action_view/helpers/form_helper.rb +875 -148
  25. data/lib/action_view/helpers/form_options_helper.rb +128 -82
  26. data/lib/action_view/helpers/form_tag_helper.rb +253 -91
  27. data/lib/action_view/helpers/javascript_helper.rb +37 -15
  28. data/lib/action_view/helpers/number_helper.rb +100 -77
  29. data/lib/action_view/helpers/output_safety_helper.rb +42 -10
  30. data/lib/action_view/helpers/rendering_helper.rb +26 -15
  31. data/lib/action_view/helpers/sanitize_helper.rb +79 -164
  32. data/lib/action_view/helpers/tag_helper.rb +277 -64
  33. data/lib/action_view/helpers/tags/base.rb +143 -92
  34. data/lib/action_view/helpers/tags/check_box.rb +20 -19
  35. data/lib/action_view/helpers/tags/checkable.rb +4 -2
  36. data/lib/action_view/helpers/tags/collection_check_boxes.rb +12 -30
  37. data/lib/action_view/helpers/tags/collection_helpers.rb +69 -36
  38. data/lib/action_view/helpers/tags/collection_radio_buttons.rb +6 -12
  39. data/lib/action_view/helpers/tags/collection_select.rb +4 -2
  40. data/lib/action_view/helpers/tags/color_field.rb +4 -3
  41. data/lib/action_view/helpers/tags/date_field.rb +3 -2
  42. data/lib/action_view/helpers/tags/date_select.rb +38 -37
  43. data/lib/action_view/helpers/tags/datetime_field.rb +14 -5
  44. data/lib/action_view/helpers/tags/datetime_local_field.rb +3 -2
  45. data/lib/action_view/helpers/tags/datetime_select.rb +2 -0
  46. data/lib/action_view/helpers/tags/email_field.rb +2 -0
  47. data/lib/action_view/helpers/tags/file_field.rb +2 -0
  48. data/lib/action_view/helpers/tags/grouped_collection_select.rb +4 -2
  49. data/lib/action_view/helpers/tags/hidden_field.rb +2 -0
  50. data/lib/action_view/helpers/tags/label.rb +41 -22
  51. data/lib/action_view/helpers/tags/month_field.rb +3 -2
  52. data/lib/action_view/helpers/tags/number_field.rb +2 -0
  53. data/lib/action_view/helpers/tags/password_field.rb +3 -1
  54. data/lib/action_view/helpers/tags/placeholderable.rb +24 -0
  55. data/lib/action_view/helpers/tags/radio_button.rb +7 -6
  56. data/lib/action_view/helpers/tags/range_field.rb +2 -0
  57. data/lib/action_view/helpers/tags/search_field.rb +3 -0
  58. data/lib/action_view/helpers/tags/select.rb +11 -10
  59. data/lib/action_view/helpers/tags/tel_field.rb +2 -0
  60. data/lib/action_view/helpers/tags/text_area.rb +7 -1
  61. data/lib/action_view/helpers/tags/text_field.rb +11 -7
  62. data/lib/action_view/helpers/tags/time_field.rb +3 -2
  63. data/lib/action_view/helpers/tags/time_select.rb +2 -0
  64. data/lib/action_view/helpers/tags/time_zone_select.rb +3 -1
  65. data/lib/action_view/helpers/tags/translator.rb +39 -0
  66. data/lib/action_view/helpers/tags/url_field.rb +2 -0
  67. data/lib/action_view/helpers/tags/week_field.rb +3 -2
  68. data/lib/action_view/helpers/tags.rb +4 -1
  69. data/lib/action_view/helpers/text_helper.rb +80 -45
  70. data/lib/action_view/helpers/translation_helper.rb +148 -67
  71. data/lib/action_view/helpers/url_helper.rb +289 -147
  72. data/lib/action_view/helpers.rb +5 -3
  73. data/lib/action_view/layouts.rb +68 -63
  74. data/lib/action_view/log_subscriber.rb +80 -13
  75. data/lib/action_view/lookup_context.rb +137 -92
  76. data/lib/action_view/model_naming.rb +4 -2
  77. data/lib/action_view/path_set.rb +30 -16
  78. data/lib/action_view/railtie.rb +62 -13
  79. data/lib/action_view/record_identifier.rb +53 -26
  80. data/lib/action_view/renderer/abstract_renderer.rb +152 -13
  81. data/lib/action_view/renderer/collection_renderer.rb +196 -0
  82. data/lib/action_view/renderer/object_renderer.rb +34 -0
  83. data/lib/action_view/renderer/partial_renderer/collection_caching.rb +102 -0
  84. data/lib/action_view/renderer/partial_renderer.rb +61 -261
  85. data/lib/action_view/renderer/renderer.rb +67 -6
  86. data/lib/action_view/renderer/streaming_template_renderer.rb +58 -54
  87. data/lib/action_view/renderer/template_renderer.rb +83 -75
  88. data/lib/action_view/rendering.rb +73 -46
  89. data/lib/action_view/routing_url_for.rb +54 -17
  90. data/lib/action_view/tasks/cache_digests.rake +25 -0
  91. data/lib/action_view/template/error.rb +44 -29
  92. data/lib/action_view/template/handlers/builder.rb +12 -13
  93. data/lib/action_view/template/handlers/erb/erubi.rb +89 -0
  94. data/lib/action_view/template/handlers/erb.rb +23 -89
  95. data/lib/action_view/template/handlers/html.rb +11 -0
  96. data/lib/action_view/template/handlers/raw.rb +4 -4
  97. data/lib/action_view/template/handlers.rb +22 -9
  98. data/lib/action_view/template/html.rb +10 -11
  99. data/lib/action_view/template/inline.rb +22 -0
  100. data/lib/action_view/template/raw_file.rb +25 -0
  101. data/lib/action_view/template/renderable.rb +24 -0
  102. data/lib/action_view/template/resolver.rb +267 -181
  103. data/lib/action_view/template/sources/file.rb +17 -0
  104. data/lib/action_view/template/sources.rb +13 -0
  105. data/lib/action_view/template/text.rb +8 -10
  106. data/lib/action_view/template/types.rb +18 -18
  107. data/lib/action_view/template.rb +109 -99
  108. data/lib/action_view/test_case.rb +73 -53
  109. data/lib/action_view/testing/resolvers.rb +24 -33
  110. data/lib/action_view/unbound_template.rb +31 -0
  111. data/lib/action_view/version.rb +3 -1
  112. data/lib/action_view/view_paths.rb +74 -44
  113. data/lib/action_view.rb +14 -9
  114. data/lib/assets/compiled/rails-ujs.js +746 -0
  115. metadata +71 -26
  116. data/lib/action_view/helpers/record_tag_helper.rb +0 -108
  117. data/lib/action_view/tasks/dependencies.rake +0 -23
  118. data/lib/action_view/vendor/html-scanner/html/document.rb +0 -68
  119. data/lib/action_view/vendor/html-scanner/html/node.rb +0 -532
  120. data/lib/action_view/vendor/html-scanner/html/sanitizer.rb +0 -188
  121. data/lib/action_view/vendor/html-scanner/html/selector.rb +0 -830
  122. data/lib/action_view/vendor/html-scanner/html/tokenizer.rb +0 -107
  123. data/lib/action_view/vendor/html-scanner/html/version.rb +0 -11
  124. data/lib/action_view/vendor/html-scanner.rb +0 -20
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ class Template
5
+ module Sources
6
+ class File
7
+ def initialize(filename)
8
+ @filename = filename
9
+ end
10
+
11
+ def to_s
12
+ ::File.binread @filename
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ class Template
5
+ module Sources
6
+ extend ActiveSupport::Autoload
7
+
8
+ eager_autoload do
9
+ autoload :File
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,22 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView #:nodoc:
2
4
  # = Action View Text Template
3
- class Template
5
+ class Template #:nodoc:
4
6
  class Text #:nodoc:
5
7
  attr_accessor :type
6
8
 
7
- def initialize(string, type = nil)
9
+ def initialize(string)
8
10
  @string = string.to_s
9
- @type = Types[type] || type if type
10
- @type ||= Types[:text]
11
11
  end
12
12
 
13
13
  def identifier
14
- 'text template'
14
+ "text template"
15
15
  end
16
16
 
17
- def inspect
18
- 'text template'
19
- end
17
+ alias_method :inspect, :identifier
20
18
 
21
19
  def to_str
22
20
  @string
@@ -26,8 +24,8 @@ module ActionView #:nodoc:
26
24
  to_str
27
25
  end
28
26
 
29
- def formats
30
- [@type.respond_to?(:ref) ? @type.ref : @type.to_s]
27
+ def format
28
+ :text
31
29
  end
32
30
  end
33
31
  end
@@ -1,23 +1,17 @@
1
- require 'set'
2
- require 'active_support/core_ext/module/attribute_accessors'
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/core_ext/module/attribute_accessors"
3
4
 
4
5
  module ActionView
5
- class Template
6
+ class Template #:nodoc:
6
7
  class Types
7
8
  class Type
8
- cattr_accessor :types
9
- self.types = Set.new
10
-
11
- def self.register(*t)
12
- types.merge(t.map { |type| type.to_s })
13
- end
14
-
15
- register :html, :text, :js, :css, :xml, :json
9
+ SET = Struct.new(:symbols).new([ :html, :text, :js, :css, :xml, :json ])
16
10
 
17
11
  def self.[](type)
18
- return type if type.is_a?(self)
19
-
20
- if type.is_a?(Symbol) || types.member?(type.to_s)
12
+ if type.is_a?(self)
13
+ type
14
+ else
21
15
  new(type)
22
16
  end
23
17
  end
@@ -28,16 +22,18 @@ module ActionView
28
22
  @symbol = symbol.to_sym
29
23
  end
30
24
 
31
- delegate :to_s, :to_sym, :to => :symbol
25
+ def to_s
26
+ @symbol.to_s
27
+ end
32
28
  alias to_str to_s
33
29
 
34
30
  def ref
35
- to_sym || to_s
31
+ @symbol
36
32
  end
33
+ alias to_sym ref
37
34
 
38
35
  def ==(type)
39
- return false if type.blank?
40
- symbol.to_sym == type.to_sym
36
+ @symbol == type.to_sym unless type.blank?
41
37
  end
42
38
  end
43
39
 
@@ -52,6 +48,10 @@ module ActionView
52
48
  def self.[](type)
53
49
  type_klass[type]
54
50
  end
51
+
52
+ def self.symbols
53
+ type_klass::SET.symbols
54
+ end
55
55
  end
56
56
  end
57
57
  end
@@ -1,6 +1,7 @@
1
- require 'active_support/core_ext/object/try'
2
- require 'active_support/core_ext/kernel/singleton_class'
3
- require 'thread'
1
+ # frozen_string_literal: true
2
+
3
+ require "thread"
4
+ require "delegate"
4
5
 
5
6
  module ActionView
6
7
  # = Action View Template
@@ -65,8 +66,7 @@ module ActionView
65
66
  # If you want to provide an alternate mechanism for
66
67
  # specifying encodings (like ERB does via <%# encoding: ... %>),
67
68
  # you may indicate that you will handle encodings yourself
68
- # by implementing <tt>self.handles_encoding?</tt>
69
- # on your handler.
69
+ # by implementing <tt>handles_encoding?</tt> on your handler.
70
70
  #
71
71
  # If you do, Rails will not try to encode the String
72
72
  # into the default_internal, passing you the unaltered
@@ -87,48 +87,57 @@ module ActionView
87
87
  # expected_encoding
88
88
  # )
89
89
 
90
+ ##
91
+ # :method: local_assigns
92
+ #
93
+ # Returns a hash with the defined local variables.
94
+ #
95
+ # Given this sub template rendering:
96
+ #
97
+ # <%= render "shared/header", { headline: "Welcome", person: person } %>
98
+ #
99
+ # You can use +local_assigns+ in the sub templates to access the local variables:
100
+ #
101
+ # local_assigns[:headline] # => "Welcome"
102
+
90
103
  eager_autoload do
91
104
  autoload :Error
105
+ autoload :RawFile
106
+ autoload :Renderable
92
107
  autoload :Handlers
93
108
  autoload :HTML
109
+ autoload :Inline
110
+ autoload :Sources
94
111
  autoload :Text
95
112
  autoload :Types
96
113
  end
97
114
 
98
115
  extend Template::Handlers
99
116
 
100
- attr_accessor :locals, :formats, :variants, :virtual_path
101
-
102
- attr_reader :source, :identifier, :handler, :original_encoding, :updated_at
103
-
104
- # This finalizer is needed (and exactly with a proc inside another proc)
105
- # otherwise templates leak in development.
106
- Finalizer = proc do |method_name, mod|
107
- proc do
108
- mod.module_eval do
109
- remove_possible_method method_name
110
- end
111
- end
112
- end
113
-
114
- def initialize(source, identifier, handler, details)
115
- format = details[:format] || (handler.default_format if handler.respond_to?(:default_format))
117
+ attr_reader :identifier, :handler
118
+ attr_reader :variable, :format, :variant, :locals, :virtual_path
116
119
 
120
+ def initialize(source, identifier, handler, locals:, format: nil, variant: nil, virtual_path: nil)
117
121
  @source = source
118
122
  @identifier = identifier
119
123
  @handler = handler
120
124
  @compiled = false
121
- @original_encoding = nil
122
- @locals = details[:locals] || []
123
- @virtual_path = details[:virtual_path]
124
- @updated_at = details[:updated_at] || Time.now
125
- @formats = Array(format).map { |f| f.respond_to?(:ref) ? f.ref : f }
126
- @variants = [details[:variant]]
125
+ @locals = locals
126
+ @virtual_path = virtual_path
127
+
128
+ @variable = if @virtual_path
129
+ base = @virtual_path.end_with?("/") ? "" : ::File.basename(@virtual_path)
130
+ base =~ /\A_?(.*?)(?:\.\w+)*\z/
131
+ $1.to_sym
132
+ end
133
+
134
+ @format = format
135
+ @variant = variant
127
136
  @compile_mutex = Mutex.new
128
137
  end
129
138
 
130
- # Returns if the underlying handler supports streaming. If so,
131
- # a streaming buffer *may* be passed when it start rendering.
139
+ # Returns whether the underlying handler supports streaming. If so,
140
+ # a streaming buffer *may* be passed when it starts rendering.
132
141
  def supports_streaming?
133
142
  handler.respond_to?(:supports_streaming?) && handler.supports_streaming?
134
143
  end
@@ -139,40 +148,29 @@ module ActionView
139
148
  # This method is instrumented as "!render_template.action_view". Notice that
140
149
  # we use a bang in this instrumentation because you don't want to
141
150
  # consume this in production. This is only slow if it's being listened to.
142
- def render(view, locals, buffer=nil, &block)
143
- instrument("!render_template") do
151
+ def render(view, locals, buffer = ActionView::OutputBuffer.new, add_to_stack: true, &block)
152
+ instrument_render_template do
144
153
  compile!(view)
145
- view.send(method_name, locals, buffer, &block)
154
+ view._run(method_name, self, locals, buffer, add_to_stack: add_to_stack, &block)
146
155
  end
147
156
  rescue => e
148
157
  handle_render_error(view, e)
149
158
  end
150
159
 
151
160
  def type
152
- @type ||= Types[@formats.first] if @formats.first
161
+ @type ||= Types[format]
153
162
  end
154
163
 
155
- # Receives a view object and return a template similar to self by using @virtual_path.
156
- #
157
- # This method is useful if you have a template object but it does not contain its source
158
- # anymore since it was already compiled. In such cases, all you need to do is to call
159
- # refresh passing in the view object.
160
- #
161
- # Notice this method raises an error if the template to be refreshed does not have a
162
- # virtual path set (true just for inline templates).
163
- def refresh(view)
164
- raise "A template needs to have a virtual path in order to be refreshed" unless @virtual_path
165
- lookup = view.lookup_context
166
- pieces = @virtual_path.split("/")
167
- name = pieces.pop
168
- partial = !!name.sub!(/^_/, "")
169
- lookup.disable_cache do
170
- lookup.find_template(name, [ pieces.join('/') ], partial, @locals)
171
- end
164
+ def short_identifier
165
+ @short_identifier ||= defined?(Rails.root) ? identifier.delete_prefix("#{Rails.root}/") : identifier
172
166
  end
173
167
 
174
168
  def inspect
175
- @inspect ||= defined?(Rails.root) ? identifier.sub("#{Rails.root}/", '') : identifier
169
+ "#<#{self.class.name} #{short_identifier} locals=#{@locals.inspect}>"
170
+ end
171
+
172
+ def source
173
+ @source.to_s
176
174
  end
177
175
 
178
176
  # This method is responsible for properly setting the encoding of the
@@ -186,12 +184,14 @@ module ActionView
186
184
  # before passing the source on to the template engine, leaving a
187
185
  # blank line in its stead.
188
186
  def encode!
189
- return unless source.encoding == Encoding::BINARY
187
+ source = self.source
188
+
189
+ return source unless source.encoding == Encoding::BINARY
190
190
 
191
191
  # Look for # encoding: *. If we find one, we'll encode the
192
192
  # String in that encoding, otherwise, we'll use the
193
193
  # default external encoding.
194
- if source.sub!(/\A#{ENCODING_FLAG}/, '')
194
+ if source.sub!(/\A#{ENCODING_FLAG}/, "")
195
195
  encoding = magic_encoding = $1
196
196
  else
197
197
  encoding = Encoding.default_external
@@ -219,11 +219,23 @@ module ActionView
219
219
  end
220
220
  end
221
221
 
222
- protected
223
222
 
223
+ # Exceptions are marshalled when using the parallel test runner with DRb, so we need
224
+ # to ensure that references to the template object can be marshalled as well. This means forgoing
225
+ # the marshalling of the compiler mutex and instantiating that again on unmarshalling.
226
+ def marshal_dump # :nodoc:
227
+ [ @source, @identifier, @handler, @compiled, @locals, @virtual_path, @format, @variant ]
228
+ end
229
+
230
+ def marshal_load(array) # :nodoc:
231
+ @source, @identifier, @handler, @compiled, @locals, @virtual_path, @format, @variant = *array
232
+ @compile_mutex = Mutex.new
233
+ end
234
+
235
+ private
224
236
  # Compile a template. This method ensures a template is compiled
225
237
  # just once and removes the source after it is compiled.
226
- def compile!(view) #:nodoc:
238
+ def compile!(view)
227
239
  return if @compiled
228
240
 
229
241
  # Templates can be used concurrently in threaded environments
@@ -235,19 +247,12 @@ module ActionView
235
247
  # re-compilation
236
248
  return if @compiled
237
249
 
238
- if view.is_a?(ActionView::CompiledTemplates)
239
- mod = ActionView::CompiledTemplates
240
- else
241
- mod = view.singleton_class
242
- end
250
+ mod = view.compiled_method_container
243
251
 
244
252
  instrument("!compile_template") do
245
- compile(view, mod)
253
+ compile(mod)
246
254
  end
247
255
 
248
- # Just discard the source if we have a virtual path. This
249
- # means we can get the template back.
250
- @source = nil if @virtual_path
251
256
  @compiled = true
252
257
  end
253
258
  end
@@ -264,18 +269,16 @@ module ActionView
264
269
  # encode the source into <tt>Encoding.default_internal</tt>.
265
270
  # In general, this means that templates will be UTF-8 inside of Rails,
266
271
  # regardless of the original source encoding.
267
- def compile(view, mod) #:nodoc:
268
- encode!
269
- method_name = self.method_name
270
- code = @handler.call(self)
272
+ def compile(mod)
273
+ source = encode!
274
+ code = @handler.call(self, source)
271
275
 
272
276
  # Make sure that the resulting String to be eval'd is in the
273
277
  # encoding of the code
274
- source = <<-end_src
278
+ original_source = source
279
+ source = +<<-end_src
275
280
  def #{method_name}(local_assigns, output_buffer)
276
- _old_virtual_path, @virtual_path = @virtual_path, #{@virtual_path.inspect};_old_output_buffer = @output_buffer;#{locals_code};#{code}
277
- ensure
278
- @virtual_path, @output_buffer = _old_virtual_path, _old_output_buffer
281
+ @virtual_path = #{@virtual_path.inspect};#{locals_code};#{code}
279
282
  end
280
283
  end_src
281
284
 
@@ -290,53 +293,60 @@ module ActionView
290
293
  # handler is valid in the default_internal. This is for handlers
291
294
  # that handle encoding but screw up
292
295
  unless source.valid_encoding?
293
- raise WrongEncodingError.new(@source, Encoding.default_internal)
296
+ raise WrongEncodingError.new(source, Encoding.default_internal)
294
297
  end
295
298
 
296
299
  begin
297
300
  mod.module_eval(source, identifier, 0)
298
- ObjectSpace.define_finalizer(self, Finalizer[method_name, mod])
299
- rescue => e # errors from template code
300
- if logger = (view && view.logger)
301
- logger.debug "ERROR: compiling #{method_name} RAISED #{e}"
302
- logger.debug "Function body: #{source}"
303
- logger.debug "Backtrace: #{e.backtrace.join("\n")}"
304
- end
305
-
306
- raise ActionView::Template::Error.new(self, e)
301
+ rescue SyntaxError
302
+ # Account for when code in the template is not syntactically valid; e.g. if we're using
303
+ # ERB and the user writes <%= foo( %>, attempting to call a helper `foo` and interpolate
304
+ # the result into the template, but missing an end parenthesis.
305
+ raise SyntaxErrorInTemplate.new(self, original_source)
307
306
  end
308
307
  end
309
308
 
310
- def handle_render_error(view, e) #:nodoc:
309
+ def handle_render_error(view, e)
311
310
  if e.is_a?(Template::Error)
312
311
  e.sub_template_of(self)
313
312
  raise e
314
313
  else
315
- template = self
316
- unless template.source
317
- template = refresh(view)
318
- template.encode!
319
- end
320
- raise Template::Error.new(template, e)
314
+ raise Template::Error.new(self)
315
+ end
316
+ end
317
+
318
+ def locals_code
319
+ # Only locals with valid variable names get set directly. Others will
320
+ # still be available in local_assigns.
321
+ locals = @locals - Module::RUBY_RESERVED_KEYWORDS
322
+ locals = locals.grep(/\A@?(?![A-Z0-9])(?:[[:alnum:]_]|[^\0-\177])+\z/)
323
+
324
+ # Assign for the same variable is to suppress unused variable warning
325
+ locals.each_with_object(+"") { |key, code| code << "#{key} = local_assigns[:#{key}]; #{key} = #{key};" }
326
+ end
327
+
328
+ def method_name
329
+ @method_name ||= begin
330
+ m = +"_#{identifier_method_name}__#{@identifier.hash}_#{__id__}"
331
+ m.tr!("-", "_")
332
+ m
321
333
  end
322
334
  end
323
335
 
324
- def locals_code #:nodoc:
325
- # Double assign to suppress the dreaded 'assigned but unused variable' warning
326
- @locals.map { |key| "#{key} = #{key} = local_assigns[:#{key}];" }.join
336
+ def identifier_method_name
337
+ short_identifier.tr("^a-z_", "_")
327
338
  end
328
339
 
329
- def method_name #:nodoc:
330
- @method_name ||= "_#{identifier_method_name}__#{@identifier.hash}_#{__id__}".gsub('-', "_")
340
+ def instrument(action, &block) # :doc:
341
+ ActiveSupport::Notifications.instrument("#{action}.action_view", instrument_payload, &block)
331
342
  end
332
343
 
333
- def identifier_method_name #:nodoc:
334
- inspect.gsub(/[^a-z_]/, '_')
344
+ def instrument_render_template(&block)
345
+ ActiveSupport::Notifications.instrument("!render_template.action_view", instrument_payload, &block)
335
346
  end
336
347
 
337
- def instrument(action, &block)
338
- payload = { virtual_path: @virtual_path, identifier: @identifier }
339
- ActiveSupport::Notifications.instrument("#{action}.action_view", payload, &block)
348
+ def instrument_payload
349
+ { virtual_path: @virtual_path, identifier: @identifier }
340
350
  end
341
351
  end
342
352
  end