Sha256: 2a132a9d2ff052d0476a834491761ac631c9989a5bd86506a3e6b192cc8f48c6

Contents?: true

Size: 1.41 KB

Versions: 7

Compression:

Stored size: 1.41 KB

Contents

module OutpostHelper
  # Public: Maps the standard Rails flash keys (+notice+, +alert+) to the
  # appropriate Bootstrap alert class (+success+, +error+ respectively).
  # Falls back to just returning the passed-in symbol as a string.
  #
  # name - The flash key as a Symbol.
  #
  # Examples
  #
  #   <div class="alert alert-<%= flash_alert_type(:notice) %>">
  #   # => <div class="alert alert-success">
  #
  # Returns String of appropriate CSS class for Bootstrap alerts.
  def flash_alert_type(name)
    name_bootstrap_map = {
      notice: "success",
      alert:  "error"
    }

    name_bootstrap_map[name.to_sym] || name.to_s
  end

  def render_flash_messages
    if flash.present?
      render '/outpost/shared/flash_messages', flash: flash
    end
  end

  def render_breadcrumbs
    if breadcrumbs.present?
      render '/outpost/shared/breadcrumbs', breadcrumbs: breadcrumbs
    end
  end

  def render_navigation
    render '/outpost/shared/navigation', current_user: current_user
  end

  # Public: Place a modal anywhere with a button to toggle it.
  #
  # options - (Hash) Options to pass into the modal template. Useful for
  #           CSS ID, and modal title.
  # block   - The block that gets captured and rendered inside of the modal.
  #
  # Returns String of rendered modal and toggle button.
  def modal_toggle(options={}, &block)
    render "/outpost/shared/modal", options: options, body: capture(&block)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
outpost-cms-0.1.4 app/helpers/outpost_helper.rb
outpost-cms-0.1.3 app/helpers/outpost_helper.rb
outpost-cms-0.1.2 app/helpers/outpost_helper.rb
outpost-cms-0.1.1 app/helpers/outpost_helper.rb
outpost-cms-0.1.0 app/helpers/outpost_helper.rb
outpost-cms-0.0.5 app/helpers/outpost_helper.rb
outpost-cms-0.0.4 app/helpers/outpost_helper.rb