Class: CCS::Components::GovUK::Footer::Link

Inherits:
Base
  • Object
show all
Defined in:
lib/ccs/components/govuk/footer/link.rb

Overview

GOV.UK Footer link

The individual footer footer link item

Constant Summary

Constants inherited from Base

Base::DEFAULT_ATTRIBUTES

Instance Method Summary collapse

Constructor Details

#initialize(text:, href:, li_class:, **options) ⇒ Link

Returns a new instance of Link.

Parameters:

  • text (String)

    the text for the footer link

  • href (String)

    the href for the footer link

  • li_class (String)

    class for the li elements

  • options (Hash)

    options that will be used in customising the HTML

Options Hash (**options):

  • :attributes (Hash)

    any additional attributes that will added as part of the HTML



32
33
34
35
36
37
38
# File 'lib/ccs/components/govuk/footer/link.rb', line 32

def initialize(text:, href:, li_class:, **options)
  super(**options)

  @text = text
  @href = href
  @li_class = li_class
end

Instance Method Details

#renderActiveSupport::SafeBuffer

Generates the HTML for the GOV.UK Footer link

Returns:

  • (ActiveSupport::SafeBuffer)


44
45
46
47
48
49
50
# File 'lib/ccs/components/govuk/footer/link.rb', line 44

def render
  tag.li(class: li_class) do
    options[:attributes][:class] = 'govuk-footer__link'

    link_to(text, href, **options[:attributes])
  end
end