Class: Railsboot::Table::CellComponent

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

Overview

ViewComponent: renders the cell block.

Constant Summary collapse

TAGS =

Tags.

%w[th td].freeze
DEFAULT_TAG =

Default tag.

"td".freeze

Instance Method Summary collapse

Constructor Details

#initialize(tag: DEFAULT_TAG, **html_attributes) ⇒ CellComponent

Returns a new instance of CellComponent.

Parameters:

  • tag (String) (defaults to: DEFAULT_TAG)

    HTML tag to render (one of TAGS)

  • html_attributes (Hash)

    additional HTML attributes applied to the rendered element

Options Hash (**html_attributes):

  • :class (String)

    additional CSS classes, merged with the component's own classes



12
13
14
15
# File 'app/components/railsboot/table/cell_component.rb', line 12

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

Instance Method Details

#callString

Renders the cell with its content.

Returns:

  • (String)

    HTML for the cell element



19
20
21
# File 'app/components/railsboot/table/cell_component.rb', line 19

def call
   @tag, content, **@html_attributes
end