Class: CCS::Components::GovUK::Tag
- Defined in:
- lib/ccs/components/govuk/tag.rb
Overview
GOV.UK Tag
This is used to generate the tag component from the GDS - Components - Tag
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the tag
{ class: 'govuk-tag' }.freeze
Instance Method Summary collapse
-
#initialize(text:, colour: nil, **options) ⇒ Tag
constructor
A new instance of Tag.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Tag component.
Constructor Details
#initialize(text:, colour: nil, **options) ⇒ Tag
Returns a new instance of Tag.
30 31 32 33 34 35 |
# File 'lib/ccs/components/govuk/tag.rb', line 30 def initialize(text:, colour: nil, **) super(**) @options[:attributes][:class][..8] = "govuk-tag govuk-tag--#{colour}" if colour @text = text end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Tag component
41 42 43 |
# File 'lib/ccs/components/govuk/tag.rb', line 41 def render tag.strong(text, **[:attributes]) end |