Class: GovukComponent::Tag
- Defined in:
- app/components/govuk_component/tag.rb
Constant Summary collapse
- COLOURS =
%w(grey green turquoise blue red purple pink orange yellow).freeze
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Attributes included from GovukComponent::Traits::CustomHtmlAttributes
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(text:, colour: nil, classes: [], html_attributes: {}) ⇒ Tag
constructor
A new instance of Tag.
Methods inherited from Base
Methods included from GovukComponent::Traits::CustomClasses
Constructor Details
#initialize(text:, colour: nil, classes: [], html_attributes: {}) ⇒ Tag
Returns a new instance of Tag.
6 7 8 9 10 11 |
# File 'app/components/govuk_component/tag.rb', line 6 def initialize(text:, colour: nil, classes: [], html_attributes: {}) super(classes: classes, html_attributes: html_attributes) @text = text @colour = colour end |
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
2 3 4 |
# File 'app/components/govuk_component/tag.rb', line 2 def text @text end |
Instance Method Details
#call ⇒ Object
13 14 15 |
# File 'app/components/govuk_component/tag.rb', line 13 def call tag.strong(@text, class: classes.append(colour_class), **html_attributes) end |