Module: Booties::FlagHelper

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

Overview

:nodoc:

Instance Method Summary collapse

Methods included from Utils

merge_classes

Instance Method Details

#flag(content = nil, context: :default, class: nil, **options, &block) ⇒ Object

Renders a Bootstrap label. The label text may be passed in through content or as a block. The context keyword may be used to specify the label context; the default context is :default. Additional HTML attributes may be passed in through the options hash.

Examples:

<%= flag 'foo' %>
foo

<%= flag do %>
  foo
<% end %>
foo

<%= flag 'foo', context: :primary %>
foo

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

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


31
32
33
34
35
36
37
# File 'app/helpers/booties/flag_helper.rb', line 31

def flag(content = nil, context: :default, class: nil, **options, &block)
  classes = merge_classes %W[label label-#{context}],
                          binding.local_variable_get(:class)
  options = { class: classes, **options }

   :span, content, options, &block
end