Sha256: 12afe425e9daf71404c2a4eb076b68b625a35e28f43fcea5c8e1856b18f886e6
Contents?: true
Size: 991 Bytes
Versions: 4
Compression:
Stored size: 991 Bytes
Contents
module GOVUKDesignSystemFormBuilder module Elements class Hint < Base using PrefixableArray include Traits::Hint include Traits::Localisation def initialize(builder, object_name, attribute_name, text, value = nil, radio: false, checkbox: false) super(builder, object_name, attribute_name) @value = value @hint_text = retrieve_text(text) @radio = radio @checkbox = checkbox end def html return nil if @hint_text.blank? tag.span(@hint_text, class: classes, id: hint_id) end private def retrieve_text(supplied) supplied.presence || localised_text(:hint) end def classes %w(hint).prefix(brand).push(radio_class, checkbox_class).compact end def radio_class @radio ? %(#{brand}-radios__hint) : nil end def checkbox_class @checkbox ? %(#{brand}-checkboxes__hint) : nil end end end end
Version data entries
4 entries across 4 versions & 1 rubygems