Class: CCS::Components::GovUK::Label
- Defined in:
- lib/ccs/components/govuk/label.rb
Overview
GOV.UK Label
This is used to generate the label component from the Government Design Systems
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the label
{ class: 'govuk-label' }.freeze
Instance Method Summary collapse
-
#initialize(attribute:, text: nil, form: nil, **options) ⇒ Label
constructor
A new instance of Label.
-
#render { ... } ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK label component.
Constructor Details
#initialize(attribute:, text: nil, form: nil, **options) ⇒ Label
Returns a new instance of Label.
34 35 36 37 38 39 40 |
# File 'lib/ccs/components/govuk/label.rb', line 34 def initialize(attribute:, text: nil, form: nil, **) super(**) @attribute = attribute @text = text @form = form end |
Instance Method Details
#render { ... } ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK label component
48 49 50 51 52 53 54 55 56 |
# File 'lib/ccs/components/govuk/label.rb', line 48 def render(&block) if [:is_page_heading] tag.h1(class: 'govuk-label-wrapper') do label_html(&block) end else label_html(&block) end end |