@@ -55,7 +55,9 @@ def partial!(*args)
55
55
if args . one? && _is_active_model? ( args . first )
56
56
_render_active_model_partial args . first
57
57
else
58
- _render_explicit_partial ( *args )
58
+ options = args . extract_options! . dup
59
+ options [ :partial ] = args . first if args . present?
60
+ _render_partial_with_options options
59
61
end
60
62
end
61
63
@@ -121,7 +123,9 @@ def array!(collection = [], *args)
121
123
options = args . first
122
124
123
125
if args . one? && _partial_options? ( options )
124
- partial! options . merge ( collection : collection )
126
+ options = options . dup
127
+ options [ :collection ] = collection
128
+ _render_partial_with_options options
125
129
else
126
130
super
127
131
end
@@ -131,7 +135,7 @@ def set!(name, object = BLANK, *args)
131
135
options = args . first
132
136
133
137
if args . one? && _partial_options? ( options )
134
- _set_inline_partial name , object , options
138
+ _set_inline_partial name , object , options . dup
135
139
else
136
140
super
137
141
end
@@ -142,14 +146,14 @@ def set!(name, object = BLANK, *args)
142
146
alias_method :method_missing , :set!
143
147
144
148
def _render_partial_with_options ( options )
145
- options . reverse_merge! locals : options . except ( :partial , :as , :collection , :cached )
146
- options . reverse_merge! ::JbuilderTemplate . template_lookup_options
149
+ options [ :locals ] ||= options . except ( :partial , :as , :collection , :cached )
150
+ options [ :handlers ] ||= ::JbuilderTemplate . template_lookup_options [ :handlers ]
147
151
as = options [ :as ]
148
152
149
153
if as && options . key? ( :collection )
150
154
collection = options . delete ( :collection ) || [ ]
151
155
partial = options . delete ( :partial )
152
- options [ :locals ] . merge! ( json : self )
156
+ options [ :locals ] [ :json ] = self
153
157
collection = EnumerableCompat . new ( collection ) if collection . respond_to? ( :count ) && !collection . respond_to? ( :size )
154
158
155
159
if options . has_key? ( :layout )
@@ -175,7 +179,7 @@ def _render_partial_with_options(options)
175
179
end
176
180
177
181
def _render_partial ( options )
178
- options [ :locals ] . merge! json : self
182
+ options [ :locals ] [ :json ] = self
179
183
@context . render options
180
184
end
181
185
@@ -231,34 +235,18 @@ def _set_inline_partial(name, object, options)
231
235
value = if object . nil?
232
236
[ ]
233
237
elsif _is_collection? ( object )
234
- _scope { _render_partial_with_options options . merge ( collection : object ) }
235
- else
236
- locals = ::Hash [ options [ :as ] , object ]
237
- _scope { _render_partial_with_options options . merge ( locals : locals ) }
238
- end
239
-
240
- set! name , value
241
- end
242
-
243
- def _render_explicit_partial ( name_or_options , locals = { } )
244
- case name_or_options
245
- when ::Hash
246
- # partial! partial: 'name', foo: 'bar'
247
- options = name_or_options
238
+ _scope do
239
+ options [ :collection ] = object
240
+ _render_partial_with_options options
241
+ end
248
242
else
249
- # partial! 'name', locals: {foo: 'bar'}
250
- if locals . one? && ( locals . keys . first == :locals )
251
- options = locals . merge ( partial : name_or_options )
252
- else
253
- options = { partial : name_or_options , locals : locals }
243
+ _scope do
244
+ options [ :locals ] = { options [ :as ] => object }
245
+ _render_partial_with_options options
254
246
end
255
- # partial! 'name', foo: 'bar'
256
- as = locals . delete ( :as )
257
- options [ :as ] = as if as . present?
258
- options [ :collection ] = locals [ :collection ] if locals . key? ( :collection )
259
247
end
260
248
261
- _render_partial_with_options options
249
+ _set_value name , value
262
250
end
263
251
264
252
def _render_active_model_partial ( object )
0 commit comments