Class: CCS::Components::GovUK::Fieldset::Legend
- Defined in:
- lib/ccs/components/govuk/fieldset/legend.rb
Overview
GOV.UK Fieldset Legend
The legend for the fieldset
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the fieldset legend
{ class: 'govuk-fieldset__legend' }.freeze
Instance Method Summary collapse
-
#initialize(text:, is_page_heading: nil, caption: nil, **options) ⇒ Legend
constructor
A new instance of Legend.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Fieldset legend.
Constructor Details
#initialize(text:, is_page_heading: nil, caption: nil, **options) ⇒ Legend
Returns a new instance of Legend.
35 36 37 38 39 40 41 |
# File 'lib/ccs/components/govuk/fieldset/legend.rb', line 35 def initialize(text:, is_page_heading: nil, caption: nil, **) super(**) @text = text @is_page_heading = is_page_heading @caption = end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Fieldset legend
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ccs/components/govuk/fieldset/legend.rb', line 47 def render tag.legend(class: [:attributes][:class]) do if is_page_heading concat(tag.span([:text], class: [:classes])) if concat(tag.h1(text, class: 'govuk-fieldset__heading')) else text end end end |