Class: GOVUKDesignSystemFormBuilder::Elements::Caption

Inherits:
Base
  • Object
show all
Includes:
Traits::HTMLAttributes, Traits::HTMLClasses, Traits::Localisation
Defined in:
lib/govuk_design_system_formbuilder/elements/caption.rb

Constant Summary

Constants included from Traits::Localisation

Traits::Localisation::BASE_NAME_REGEXP

Instance Method Summary collapse

Methods included from Traits::HTMLClasses

#build_classes

Methods included from Traits::HTMLAttributes

#attributes

Methods inherited from Base

#field_id, #to_s

Constructor Details

#initialize(builder, object_name, attribute_name, text: nil, size: config.default_caption_size, **kwargs) ⇒ Caption

Returns a new instance of Caption.



8
9
10
11
12
13
14
# File 'lib/govuk_design_system_formbuilder/elements/caption.rb', line 8

def initialize(builder, object_name, attribute_name, text: nil, size: config.default_caption_size, **kwargs)
  super(builder, object_name, attribute_name)

  @text            = text(text)
  @size_class      = size_class(size)
  @html_attributes = kwargs
end

Instance Method Details

#htmlObject



16
17
18
19
20
# File 'lib/govuk_design_system_formbuilder/elements/caption.rb', line 16

def html
  return unless active?

  tag.span(@text, **attributes(@html_attributes))
end