Class: CCS::Components::GovUK::BackLink

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

Overview

GOV.UK Back Link

This is used to generate the back link component from the GDS - Components - Back link

Constant Summary collapse

DEFAULT_ATTRIBUTES =

The default attributes for the back link

{ class: 'govuk-back-link' }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(text:, href:, **options) ⇒ BackLink

Returns a new instance of BackLink.

Parameters:

  • text (String)

    the text for the back link

  • href (String)

    the href for the back link

  • options (Hash)

    options that will be used in customising the HTML

Options Hash (**options):

  • :classes (String)

    additional CSS classes for the back link HTML

  • :attributes (Hash) — default: {}

    any additional attributes that will added as part of the HTML



30
31
32
33
34
35
# File 'lib/ccs/components/govuk/back_link.rb', line 30

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

  @text = text
  @href = href
end

Instance Method Details

#renderActiveSupport::SafeBuffer

Generates the HTML for the GOV.UK Back link component

Returns:

  • (ActiveSupport::SafeBuffer)


41
42
43
# File 'lib/ccs/components/govuk/back_link.rb', line 41

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