Class: Fortitude::Rails::Renderer
- Inherits:
-
Object
- Object
- Fortitude::Rails::Renderer
- Defined in:
- lib/fortitude/rails/renderer.rb
Class Method Summary collapse
-
.render(widget_class, template_handler, local_assigns, is_partial, &block) ⇒ Object
TODO: Refactor this and render :widget => …
- .render_file(template_identifier, view_paths, template_handler, local_assigns, &block) ⇒ Object
Class Method Details
.render(widget_class, template_handler, local_assigns, is_partial, &block) ⇒ Object
TODO: Refactor this and render :widget => … support into one method somewhere.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fortitude/rails/renderer.rb', line 29 def render(, template_handler, local_assigns, is_partial, &block) if ::Fortitude::Erector.() return ::Erector::Rails.render(, template_handler, local_assigns, is_partial, &block) end total_assigns = template_handler.assigns.symbolize_keys.merge(local_assigns.symbolize_keys) needed_assigns = if .extra_assigns == :use total_assigns else .extract_needed_assigns_from(total_assigns) end = .new(needed_assigns) template_handler.with_output_buffer do rendering_context = template_handler.controller.fortitude_rendering_context_for(template_handler, block) # TODO: Refactor this -- both passing it into the constructor and setting yield_block here is gross. # # We need to call #with_yield_block here, because we can actually be invoked with different yield blocks # in the case of "partial layouts" (which most people probably don't even realize exist); we use the same # RC for both the initial view rendering and for the partial layout, but they need different yield blocks. # Yuck, but this does the job. rendering_context.with_yield_block(block) do .render_to(rendering_context) end rendering_context.flush! end end |
.render_file(template_identifier, view_paths, template_handler, local_assigns, &block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fortitude/rails/renderer.rb', line 13 def render_file(template_identifier, view_paths, template_handler, local_assigns, &block) = view_paths.map do |path| File.(path.to_s, ::Rails.root.to_s) end valid_base_classes = [ ::Fortitude::Widget, ::Fortitude::Erector. ].compact = ::Fortitude::Widget.(template_identifier, :root_dirs => , :valid_base_classes => valid_base_classes) is_partial = !! File.basename(template_identifier) =~ /^_/ render(, template_handler, local_assigns, is_partial, &block) end |