Module: Booties::BadgeHelper

Includes:
Utils
Defined in:
app/helpers/booties/badge_helper.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from Utils

merge_classes

Instance Method Details

#badge(content = nil, class: nil, **options, &block) ⇒ Object

Renders a Bootstrap badge. The text inside the badge may passed in through content or with a block. Additional HTML attributes may be passed in through the options hash.

Examples:

<%= badge 'foo' %>
foo

<%= badge do %>
  foo
<% end %>
foo

<%= badge 'foo', id: 'bar' %>
foo

<%= badge 'foo', class: 'bar' %>
foo


27
28
29
30
31
32
# File 'app/helpers/booties/badge_helper.rb', line 27

def badge(content = nil, class: nil, **options, &block)
  classes = merge_classes ['badge'], binding.local_variable_get(:class)
  options = { class: classes, **options }

   :span, content, options, &block
end