Module: Sidekiq::Tasks::Web::Helpers::TagHelper

Extended by:
TagHelper
Included in:
PaginationHelper, TagHelper, TaskHelper
Defined in:
lib/sidekiq/tasks/web/helpers/tag_helper.rb

Instance Method Summary collapse

Instance Method Details

#build_classes(*classes, **conditions) ⇒ Object



15
16
17
18
19
# File 'lib/sidekiq/tasks/web/helpers/tag_helper.rb', line 15

def build_classes(*classes, **conditions)
  condition_classes = conditions.select { |_, value| value }.keys

  (classes + condition_classes).join(" ")
end

#build_tag(tag, content = nil, **attributes, &block) ⇒ Object



8
9
10
11
12
13
# File 'lib/sidekiq/tasks/web/helpers/tag_helper.rb', line 8

def build_tag(tag, content = nil, **attributes, &block)
  attr_string = attributes.map { |key, value| "#{key}=\"#{value}\"" }.join(" ")
  attr_string = " #{attr_string}" unless attr_string.empty?

  "<#{tag}#{attr_string}>#{block&.call || content}</#{tag}>"
end