Sha256: 3fcb90e63afece81d917db3641be65ed7a78f5cc51cd260bac0e9cf45d271e06
Contents?: true
Size: 1.49 KB
Versions: 6
Compression:
Stored size: 1.49 KB
Contents
require 'erb' module Voom module Presenters module WebClient # This class renders a given component. # First it looks for plugins that override default behavior # If they don't exist then it renders the base components class ComponentRenderer extend Pluggable include_plugins(:WebClientComponents) def initialize(comp, render:, components:, index:, scope: nil) @comp = comp @index = index @components = components @scope = scope @render = render initialize_plugins end def render comp = ComponentDecoratorFactory.build(@comp) components = @components.map { |c| ComponentDecoratorFactory.build(c) } return public_send(:"render_#{@scope ? "_#{@scope}_" : nil}#{@comp.type}", comp, components: components, index: @index, render: @render) if respond_to?(:"render_#{@comp.type}") @render.call :erb, :"components#{@scope ? "/#{@scope}" : nil}/#{@comp.type}", :locals => {comp: comp, components: components, index: @index} end private def initialize_plugins self.class.include_plugins(:WebClientComponents, plugins: @comp.send(:_plugins_)) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems