Class: GOVUKDesignSystemFormBuilder::Elements::Legend
- Defined in:
- lib/govuk_design_system_formbuilder/elements/legend.rb
Constant Summary
Constants included from Traits::Localisation
Traits::Localisation::BASE_NAME_REGEXP
Instance Method Summary collapse
- #html ⇒ Object
-
#initialize(builder, object_name, attribute_name, text: nil, size: config.default_legend_size, hidden: false, tag: config.default_legend_tag, caption: nil, content: nil, **kwargs) ⇒ Legend
constructor
A new instance of Legend.
Methods included from Traits::HTMLClasses
Methods included from Traits::HTMLAttributes
Methods inherited from Base
Constructor Details
#initialize(builder, object_name, attribute_name, text: nil, size: config.default_legend_size, hidden: false, tag: config.default_legend_tag, caption: nil, content: nil, **kwargs) ⇒ Legend
Returns a new instance of Legend.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/govuk_design_system_formbuilder/elements/legend.rb', line 11 def initialize(builder, object_name, attribute_name, text: nil, size: config.default_legend_size, hidden: false, tag: config.default_legend_tag, caption: nil, content: nil, **kwargs) super(builder, object_name, attribute_name) if content @content = capture { content.call } else @text = retrieve_text(text) @tag = tag @size_class = size_class(size) @tag = tag @caption = @hidden = hidden @html_attributes = kwargs end end |
Instance Method Details
#html ⇒ Object
27 28 29 |
# File 'lib/govuk_design_system_formbuilder/elements/legend.rb', line 27 def html @content || legend end |