Class: CCS::Components::GovUK::Header::Link
- Defined in:
- lib/ccs/components/govuk/header/link.rb
Overview
GOV.UK Header link
The individual header link item
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 Header link.
Constructor Details
#initialize(text:, href: nil, **options) ⇒ Link
Returns a new instance of Link.
30 31 32 33 34 35 |
# File 'lib/ccs/components/govuk/header/link.rb', line 30 def initialize(text:, href: nil, **) super(**) @text = text @href = href end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Header link
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ccs/components/govuk/header/link.rb', line 41 def render tag.li(class: "govuk-header__navigation-item #{'govuk-header__navigation-item--active' if [:active]}".rstrip) do if href [:attributes][:class] = 'govuk-header__link' link_to(text, href, **[:attributes]) else text end end end |