Sha256: a69d4730da1bbb4012c79d7ad79657112e8b6066770565aaacb7b2ace7ea577a

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

require_relative '../../base'

module CCS::Components
  module GovUK
    class ErrorSummary < Base
      # = GOV.UK Error Summary Item
      #
      # The individual list item for the error summary
      #
      # @!attribute [r] text
      #   @return [String] Text for the error message item
      # @!attribute [r] href
      #   @return [String] The href for the error message

      class Item < Base
        private

        attr_reader :text, :href

        public

        # @param text [String] the text for the error link item
        # @param href [String] the href for the error link item.
        #                      If provided item will be a link
        # @param options [Hash] options that will be used in customising the HTML
        #
        # @option options [Hash] :attributes any additional attributes that will added as part of the HTML.

        def initialize(text:, href: nil, **options)
          super(**options)

          @text = text
          @href = href
        end

        # Generates the HTML for the GOV.UK Error Summary Item
        #
        # @return [ActiveSupport::SafeBuffer]

        def render
          tag.li do
            if href
              link_to(text, href, **options[:attributes])
            else
              text
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ccs-frontend_helpers-0.1.0.rc.2 lib/ccs/components/govuk/error_summary/item.rb