Module: Booties::FlagHelper
- Includes:
- Utils
- Defined in:
- app/helpers/booties/flag_helper.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#flag(content = nil, context: :default, class: nil, **options, &block) ⇒ Object
Renders a Bootstrap label.
Methods included from Utils
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' %>
31 32 33 34 35 36 37 |
# File 'app/helpers/booties/flag_helper.rb', line 31 def flag(content = nil, context: :default, class: nil, **, &block) classes = merge_classes %W[label label-#{context}], binding.local_variable_get(:class) = { class: classes, ** } content_tag :span, content, , &block end |