Class: Thredded::ViewHooks::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/thredded/view_hooks/renderer.rb

Instance Method Summary collapse

Constructor Details

#initialize(view_context, config) ⇒ Renderer

Returns a new instance of Renderer.

Parameters:


7
8
9
10
# File 'lib/thredded/view_hooks/renderer.rb', line 7

def initialize(view_context, config)
  @view_context = view_context
  @config = config
end

Instance Method Details

#render(**args, &original_content) ⇒ String

Returns:

  • (String)

13
14
15
16
17
18
19
# File 'lib/thredded/view_hooks/renderer.rb', line 13

def render(**args, &original_content)
  @view_context.safe_join [
    *@config.before,
    *(@config.replace.presence || [original_content]),
    *@config.after,
  ].map { |proc| render_proc(**args, &proc) }, ''
end