class AppActionListComponent::Item
Public Class Methods
Source
# File app/components/app_action_list_component.rb, line 17 def initialize(text: nil, href: nil, visually_hidden_text: nil) @text = html_escape(text) @href = href @visually_hidden_text = visually_hidden_text end
Public Instance Methods
Source
# File app/components/app_action_list_component.rb, line 23 def call label = content || @text if @visually_hidden_text.present? label = safe_join( [ label, tag.span( " #{@visually_hidden_text}", class: "nhsuk-u-visually-hidden" ) ] ) end if @href.present? link_to(label, @href) elsif label.present? label else raise(ArgumentError, "no text or content") end end