Module: ModeratorHelper

Defined in:
app/helpers/moderator_helper.rb

Overview

Provides helper methods for use by views under ModeratorController.

Instance Method Summary collapse

Instance Method Details

#text_bg(cls, content = nil, **opts) {|context| ... } ⇒ ActiveSupport::SafeBuffer

Display text on a specified background color. For instance, if the background color is dark, consider passing a class for a light text color.

Parameters:

  • cls (String)

    The background color class.

  • content (String) (defaults to: nil)

    The text to display. For uses beyond simple text, pass a block instead.

  • opts (Hash)

    a customizable set of options

Options Hash (**opts):

  • :class (String)

    Additional classes to add to the element.

Yield Parameters:

  • context (ActionView::Helpers::TagHelper::TagBuilder)

Yield Returns:

  • (ActiveSupport::SafeBuffer, String)

Returns:

  • (ActiveSupport::SafeBuffer)


12
13
14
15
16
17
18
# File 'app/helpers/moderator_helper.rb', line 12

def text_bg(cls, content = nil, **opts, &block)
  if block_given?
    tag.span class: ["has-background-color-#{cls}", opts[:class]].join(' '), &block
  else
    tag.span content, class: ["has-background-color-#{cls}", opts[:class]].join(' ')
  end
end