Module: CCS::FrontendHelpers::GovUKFrontend::WarningText

Included in:
CCS::FrontendHelpers::GovUKFrontend
Defined in:
lib/ccs/frontend_helpers/govuk_frontend/warning_text.rb

Overview

GOV.UK Warning text

This helper is used for generating the warning text component from the GDS - Components - Warning text

Instance Method Summary collapse

Instance Method Details

#govuk_warning_text(text = nil, **options) { ... } ⇒ ActiveSupport::SafeBuffer

Generates the HTML for the GOV.UK Warning text component

Parameters:

  • text (String) (defaults to: nil)

    (nil) the text for the warning If nil, then a block will be rendered

  • options (Hash)

    options that will be used in customising the HTML

Options Hash (**options):

  • :classes (String)

    additional CSS classes for the tag HTML

  • :icon_fallback_text (String)

    the fallback text for the icon (default: ‘Warning’)

  • :attributes (Hash) — default: {}

    any additional attributes that will added as part of the HTML

Yields:

  • HTML that will be used in the warning text. Ignored if text is passed.

Returns:

  • (ActiveSupport::SafeBuffer)


24
25
26
# File 'lib/ccs/frontend_helpers/govuk_frontend/warning_text.rb', line 24

def govuk_warning_text(text = nil, **options, &)
  Components::GovUK::WarningText.new(context: self, text: text, **options).render(&)
end