Class: GOVUKDesignSystemFormBuilder::Elements::Caption

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

Instance Method Summary collapse

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.



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

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



14
15
16
17
18
# File 'lib/govuk_design_system_formbuilder/elements/caption.rb', line 14

def html
  return unless active?

  tag.span(@text, class: @size_class, **@html_attributes)
end