Class: ActionComponent::Component::Renderer

Inherits:
ActionView::Renderer
  • Object
show all
Defined in:
lib/actioncomponent/component/renderer.rb

Defined Under Namespace

Classes: ComponentTemplateFileNotFound

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lookup_context, view_model) ⇒ Renderer

Returns a new instance of Renderer.



9
10
11
12
# File 'lib/actioncomponent/component/renderer.rb', line 9

def initialize(lookup_context, view_model)
  @lookup_context = lookup_context
  @view_model = view_model
end

Instance Attribute Details

#view_modelvoid (readonly)

Returns the value of attribute view_model.



7
8
9
# File 'lib/actioncomponent/component/renderer.rb', line 7

def view_model
  @view_model
end

Instance Method Details

#render(component_path:) ⇒ void



14
15
16
17
# File 'lib/actioncomponent/component/renderer.rb', line 14

def render(component_path:)
  file_path = template_path_from_component_path(component_path)
  super(view_model, file: file_path)
end

#template_path_from_component_path(component_path, template_file_name: ActionComponent.configuration.template_file_name) ⇒ void



19
20
21
# File 'lib/actioncomponent/component/renderer.rb', line 19

def template_path_from_component_path(component_path, template_file_name: ActionComponent.configuration.template_file_name)
  File.join(component_path, template_file_name).to_s
end