Class: CCS::Components::GovUK::Accordion::Section::Content

Inherits:
Object
  • Object
show all
Includes:
ActionView::Context, ActionView::Helpers
Defined in:
lib/ccs/components/govuk/accordion/section/content.rb

Overview

GOV.UK Accordion Section Content

The individual accordion section content

Instance Method Summary collapse

Constructor Details

#initialize(section:, accordion_id:, index:) ⇒ Content

Returns a new instance of Content.

Parameters:

  • section (Hash)

    attributes for the accordion section

  • accordion_id (String)

    ID of the accordion

  • index (Integer)

    the index of the accordion section



33
34
35
36
37
# File 'lib/ccs/components/govuk/accordion/section/content.rb', line 33

def initialize(section:, accordion_id:, index:)
  @section = section
  @accordion_id = accordion_id
  @index = index
end

Instance Method Details

#renderActiveSupport::SafeBuffer

Generates the HTML for the GOV.UK Accordion Section Content

Returns:

  • (ActiveSupport::SafeBuffer)


43
44
45
46
47
# File 'lib/ccs/components/govuk/accordion/section/content.rb', line 43

def render
  tag.div(class: 'govuk-accordion__section-content', id: "#{accordion_id}-content-#{index}") do
    section[:content] || tag.p(section[:text], class: 'govuk-body')
  end
end