class Mtl::Rails::NavbarPresenter

Private Specialised renderer for the navbar element

Attributes

view[R]

Public Class Methods

new(view) click to toggle source
# File lib/mtl/rails/navbar_presenter.rb, line 8
def initialize(view)
  @view = view
  @extended_options = {}
  @extended_block = nil
end

Public Instance Methods

extended(options = {}, &block) click to toggle source
# File lib/mtl/rails/navbar_presenter.rb, line 23
def extended(options = {}, &block)
  @extended_options = options
  @extended_block = view.capture(&block)
  nil
end
render(options = {}, &block) click to toggle source
# File lib/mtl/rails/navbar_presenter.rb, line 14
def render(options = {}, &block)
  nav = view.content_tag :nav, view.safe_join([render_main(options, &block),
                                               render_extended(@extended_block, @extended_options)].compact),
                         class: @extended_block ? 'nav-extended' : nil

  return nav unless options[:fixed]
  view.content_tag :div, nav, class: ['navbar-fixed', @extended_block ? 'navbar-fixed-extended' : nil]
end

Private Instance Methods

render_extended(content, options = {}) click to toggle source
# File lib/mtl/rails/navbar_presenter.rb, line 35
def render_extended(content, options = {})
  return unless content.presence
  view.content_tag(:div, content, class: [options[:class], 'nav-content'].flatten.compact)
end
render_main(options = {}, &block) click to toggle source
# File lib/mtl/rails/navbar_presenter.rb, line 31
def render_main(options = {}, &block)
  view.content_tag(:div, view.capture(self, &block), class: [options[:class], 'nav-wrapper'].flatten.compact)
end