Class: CCS::Components::GovUK::SummaryList::Action::Link
- Defined in:
- lib/ccs/components/govuk/summary_list/action/link.rb
Overview
GOV.UK Summary list action link
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the summary list action link
{ class: 'govuk-link' }.freeze
Instance Method Summary collapse
-
#initialize(text:, href:, visually_hidden_text: nil, card_title: nil, **options) ⇒ Link
constructor
A new instance of Link.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Summary list action link.
Constructor Details
#initialize(text:, href:, visually_hidden_text: nil, card_title: nil, **options) ⇒ Link
Returns a new instance of Link.
35 36 37 38 39 40 41 42 |
# File 'lib/ccs/components/govuk/summary_list/action/link.rb', line 35 def initialize(text:, href:, visually_hidden_text: nil, card_title: nil, **) super(**) @text = text @href = href @visually_hidden_text = visually_hidden_text @card_title = card_title end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Summary list action link
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ccs/components/govuk/summary_list/action/link.rb', line 48 def render link_to(href, **@options[:attributes]) do concat(text) if visually_hidden_text.present? || card_title.present? concat(tag.span(class: 'govuk-visually-hidden') do if visually_hidden_text concat(' ') concat(visually_hidden_text) end if card_title concat(' ') concat("(#{card_title})") end end) end end end |