Module: OutpostHelper
- Defined in:
- app/helpers/outpost_helper.rb
Instance Method Summary collapse
-
#flash_alert_type(name) ⇒ Object
Public: Maps the standard Rails flash keys (
notice
,alert
) to the appropriate Bootstrap alert class (success
,error
respectively). -
#modal_toggle(options = {}, &block) ⇒ Object
Public: Place a modal anywhere with a button to toggle it.
- #render_breadcrumbs ⇒ Object
- #render_flash_messages ⇒ Object
- #render_navigation ⇒ Object
Instance Method Details
#flash_alert_type(name) ⇒ Object
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.
14 15 16 17 18 19 20 21 |
# File 'app/helpers/outpost_helper.rb', line 14 def flash_alert_type(name) name_bootstrap_map = { notice: "success", alert: "error" } name_bootstrap_map[name.to_sym] || name.to_s end |
#modal_toggle(options = {}, &block) ⇒ Object
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.
46 47 48 |
# File 'app/helpers/outpost_helper.rb', line 46 def modal_toggle(={}, &block) render "/outpost/shared/modal", options: , body: capture(&block) end |
#render_breadcrumbs ⇒ Object
29 30 31 32 33 |
# File 'app/helpers/outpost_helper.rb', line 29 def if .present? render '/outpost/shared/breadcrumbs', breadcrumbs: end end |
#render_flash_messages ⇒ Object
23 24 25 26 27 |
# File 'app/helpers/outpost_helper.rb', line 23 def if flash.present? render '/outpost/shared/flash_messages', flash: flash end end |
#render_navigation ⇒ Object
35 36 37 |
# File 'app/helpers/outpost_helper.rb', line 35 def render '/outpost/shared/navigation', current_user: current_user end |