4
4
require 'active_support/cache'
5
5
6
6
class JbuilderTemplate < Jbuilder
7
- class << self
8
- attr_accessor :template_lookup_options
9
- end
10
-
11
- self . template_lookup_options = { handlers : [ :jbuilder ] }
7
+ HANDLERS = [ :jbuilder ] . freeze
12
8
13
9
def initialize ( context , *args )
14
10
@context = context
@@ -137,14 +133,14 @@ def set!(name, object = BLANK, *args)
137
133
private
138
134
139
135
def _render_partial_with_options ( options )
140
- options . reverse_merge! locals : options . except ( :partial , :as , :collection , :cached )
141
- options . reverse_merge! ::JbuilderTemplate . template_lookup_options
136
+ options [ :locals ] ||= options . except ( :partial , :as , :collection , :cached )
137
+ options [ :handlers ] ||= ::JbuilderTemplate :: HANDLERS
142
138
as = options [ :as ]
143
139
144
140
if as && options . key? ( :collection ) && CollectionRenderer . supported?
145
141
collection = options . delete ( :collection ) || [ ]
146
142
partial = options . delete ( :partial )
147
- options [ :locals ] . merge! ( json : self )
143
+ options [ :locals ] [ :json ] = self
148
144
collection = EnumerableCompat . new ( collection ) if collection . respond_to? ( :count ) && !collection . respond_to? ( :size )
149
145
150
146
if options . has_key? ( :layout )
@@ -173,8 +169,8 @@ def _render_partial_with_options(options)
173
169
locals = options . delete ( :locals )
174
170
array! collection do |member |
175
171
member_locals = locals . clone
176
- member_locals . merge! collection : collection
177
- member_locals . merge! as => member
172
+ member_locals [ :collection ] = collection
173
+ member_locals [ as ] = member
178
174
_render_partial options . merge ( locals : member_locals )
179
175
end
180
176
else
@@ -186,7 +182,7 @@ def _render_partial_with_options(options)
186
182
end
187
183
188
184
def _render_partial ( options )
189
- options [ :locals ] . merge! json : self
185
+ options [ :locals ] [ :json ] = self
190
186
@context . render options
191
187
end
192
188
0 commit comments