Class: CCS::Components::GovUK::Breadcrumbs::Link
- Defined in:
- lib/ccs/components/govuk/breadcrumbs/link.rb
Overview
GOV.UK Breadcrumbs Link
The individual list item for the breadcrumbs
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
-
#initialize(text:, href: nil, **options) ⇒ Link
constructor
A new instance of Link.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Breadcrumbs link.
Constructor Details
#initialize(text:, href: nil, **options) ⇒ Link
Returns a new instance of Link.
31 32 33 34 35 36 |
# File 'lib/ccs/components/govuk/breadcrumbs/link.rb', line 31 def initialize(text:, href: nil, **) super(**) @text = text @href = href end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Breadcrumbs link
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ccs/components/govuk/breadcrumbs/link.rb', line 42 def render if href.present? [:attributes][:class] = 'govuk-breadcrumbs__link' tag.li(class: 'govuk-breadcrumbs__list-item') do link_to(text, href, **[:attributes]) end else tag.li(text, class: 'govuk-breadcrumbs__list-item', aria: { current: 'page' }) end end |