Module: TemplateStreaming::View
- Defined in:
- lib/template_streaming.rb
Defined Under Namespace
Classes: DeferredPartialRender
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#streaming_template=(value) ⇒ Object
Sets the attribute streaming_template
264
265
266
|
# File 'lib/template_streaming.rb', line 264
def streaming_template=(value)
@streaming_template = value
end
|
Class Method Details
.included(base) ⇒ Object
235
236
237
238
|
# File 'lib/template_streaming.rb', line 235
def self.included(base)
base.alias_method_chain :render, :template_streaming
base.alias_method_chain :_render_with_layout, :template_streaming
end
|
Instance Method Details
#_render_with_layout_with_template_streaming(options, local_assigns, &block) ⇒ Object
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
|
# File 'lib/template_streaming.rb', line 270
def _render_with_layout_with_template_streaming(options, local_assigns, &block)
if !streaming_template?
_render_with_layout_without_template_streaming(options, local_assigns, &block)
elsif block_given?
original_proc_for_layout = @_proc_for_layout
begin
_render_with_layout_without_template_streaming(options, local_assigns, &block)
ensure
@_proc_for_layout = original_proc_for_layout
end
elsif options[:layout].is_a?(ActionView::Template)
layout = options.delete(:layout)
with_render_proc_for_layout(options) do
render(options.merge(:file => layout.path_without_format_and_extension))
end
else
layout = options.delete(:layout)
with_render_proc_for_layout(options) do
if (options[:inline] || options[:file] || options[:text])
render(:file => layout, :locals => local_assigns)
else
render(options.merge(:partial => layout))
end
end
end
end
|
#render_with_template_streaming(*args, &block) ⇒ Object
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
# File 'lib/template_streaming.rb', line 240
def render_with_template_streaming(*args, &block)
options = args.first
if streaming_template? && options.is_a?(Hash)
if options[:toplevel_render_with_layout] && (partial = options[:partial])
options.delete(:toplevel_render_with_layout)
return DeferredPartialRender.new(args)
elsif options[:text].is_a?(DeferredPartialRender)
render = options.delete(:text)
return render(render.args.first.merge(:layout => options[:layout]))
end
end
render_without_template_streaming(*args, &block)
end
|
#streaming_template? ⇒ Boolean
266
267
268
|
# File 'lib/template_streaming.rb', line 266
def streaming_template?
@streaming_template
end
|
#with_render_proc_for_layout(options) ⇒ Object
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
# File 'lib/template_streaming.rb', line 299
def with_render_proc_for_layout(options)
original_proc_for_layout = @_proc_for_layout
@_proc_for_layout = lambda do |*args|
if args.empty?
render(options)
else
instance_variable_get(:"@content_for_#{args.first}")
end
end
begin
yield
ensure
@_proc_for_layout = original_proc_for_layout
end
end
|