Class: Railsboot::BaseComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/railsboot/base_component.rb

Overview

ViewComponent: renders the base block.

Instance Method Summary collapse

Constructor Details

#initialize(tag:, **html_attributes) ⇒ BaseComponent

Returns a new instance of BaseComponent.

Parameters:

  • tag (String)

    the tag option

  • html_attributes (Hash)

    additional HTML attributes applied to the rendered element

Options Hash (**html_attributes):

  • :class (String)

    CSS classes applied to the rendered tag



7
8
9
10
# File 'app/components/railsboot/base_component.rb', line 7

def initialize(tag:, **html_attributes)
  @tag = tag
  @html_attributes = html_attributes
end

Instance Method Details

#callString

Renders the component's tag wrapping its content.

Returns:

  • (String)

    the rendered HTML



14
15
16
17
18
# File 'app/components/railsboot/base_component.rb', line 14

def call
  (@tag, **@html_attributes) do
    content
  end
end