Class: GOVUKDesignSystemFormBuilder::Elements::Legend
- Includes:
- Traits::Caption, Traits::Localisation
- Defined in:
- lib/govuk_design_system_formbuilder/elements/legend.rb
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 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.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/govuk_design_system_formbuilder/elements/legend.rb', line 7 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 = caption @hidden = hidden @html_attributes = kwargs end end |
Instance Method Details
#html ⇒ Object
23 24 25 |
# File 'lib/govuk_design_system_formbuilder/elements/legend.rb', line 23 def html @content || legend end |