Class: CCS::Components::GovUK::Field::Input::CharacterCount::CountMessage
- Inherits:
-
Object
- Object
- CCS::Components::GovUK::Field::Input::CharacterCount::CountMessage
- Includes:
- ActionView::Context, ActionView::Helpers
- Defined in:
- lib/ccs/components/govuk/field/input/character_count/count_message.rb
Overview
GOV.UK Character count message
This is used to generate the character count message
Instance Method Summary collapse
-
#initialize(character_count_attribute:, context:, character_count_options:, after_input: nil) ⇒ CountMessage
constructor
A new instance of CountMessage.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Character count message.
Constructor Details
#initialize(character_count_attribute:, context:, character_count_options:, after_input: nil) ⇒ CountMessage
Returns a new instance of CountMessage.
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ccs/components/govuk/field/input/character_count/count_message.rb', line 33 def initialize(character_count_attribute:, context:, character_count_options:, after_input: nil) = [:textarea_description] || {} = [:maxwords] || [:maxlength] = "You can enter up to %<count>s #{[:maxwords] ? 'words' : 'characters'}" text = ? format([:count_message] || , count: ) : '' classes = "govuk-character-count__message #{[:classes]}".rstrip @count_message = Hint.new(text: text, classes: classes, attributes: { id: "#{character_count_attribute}-info" }, context: context) @after_input = after_input end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Character count message
50 51 52 53 54 55 |
# File 'lib/ccs/components/govuk/field/input/character_count/count_message.rb', line 50 def render capture do concat(.render) concat(after_input) if after_input end end |