Module: Spurs::Nav::Helper

Defined in:
lib/spurs/nav/helper.rb

Instance Method Summary collapse

Instance Method Details

#spurs_nav(options = { }, &block) ⇒ Object

Build a navigation :type can be either :pills or :tabs :style applies to ul



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/spurs/nav/helper.rb', line 9

def spurs_nav(options={ }, &block)

  opts        = Spurs::Nav::nav_default_options.merge(options)
  if !opts[:builder]
    raise "Null builder"
  end

  opts_to_pass_to_builder = {}
  if opts[:dynamic]
    opts_to_pass_to_builder[:dynamic] = opts[:dynamic]
  end

  if !opts[:type].in? [:pills,:tabs,:list]
    Rails.logger.debug("WARNING: unknown spurs_nav flavor. Using tabs instead")
    opts[:type] = :tabs
  end

  nav_builder = opts[:builder].new(controller,opts_to_pass_to_builder)

  output = capture(nav_builder, &block)

  ul_args = {
      :class => "nav nav-#{opts[:type]} #{opts[:stacked] ? "nav-stacked" : ""} #{opts[:class] ? opts[:class] : ""}"
  }

  if defined?(opts[:style]) then
    ul_args[:style] = opts[:style]
  end

  (:ul, output, ul_args)
end