Class: TwitterBootstrapBuilder::Builders::NavListBuilder

Inherits:
Base
  • Object
show all
Defined in:
lib/twitter_bootstrap_builder/builders/nav_list_builder.rb

Instance Attribute Summary

Attributes inherited from Base

#block, #options, #template

Instance Method Summary collapse

Methods inherited from Base

#html_safe, #initialize

Constructor Details

This class inherits a constructor from TwitterBootstrapBuilder::Builders::Base

Instance Method Details



24
25
26
# File 'lib/twitter_bootstrap_builder/builders/nav_list_builder.rb', line 24

def active_link_to(*args, &block)
  Tag.block(:li, template.link_to(*args, &block), class: 'active').to_s.html_safe
end

#custom(&block) ⇒ Object



32
33
34
# File 'lib/twitter_bootstrap_builder/builders/nav_list_builder.rb', line 32

def custom(&block)
  Tag.block(:li, template.capture(self, &block)).to_s.html_safe
end

#dividerObject



28
29
30
# File 'lib/twitter_bootstrap_builder/builders/nav_list_builder.rb', line 28

def divider
  Tag.block(:li, Divider.horizontal).to_s.html_safe
end

#header(text) ⇒ Object



11
12
13
# File 'lib/twitter_bootstrap_builder/builders/nav_list_builder.rb', line 11

def header(text)
  NavHeader.new(text).to_s.html_safe
end


15
16
17
18
19
20
21
22
# File 'lib/twitter_bootstrap_builder/builders/nav_list_builder.rb', line 15

def link_to(*args, &block)
  options = args.select { |a| a.is_a?(Hash) }.first || {}
  if options[:active_if].is_a?(Proc) ? options[:active_if].call : options[:active_if]
    active_link_to(*args, &block)
  else
    Tag.block(:li, template.link_to(*args, &block)).to_s.html_safe
  end
end

#to_sObject



5
6
7
8
9
# File 'lib/twitter_bootstrap_builder/builders/nav_list_builder.rb', line 5

def to_s
  nav_list = NavList.new
  nav_list.append template.capture(self, &block) if block
  nav_list.to_s
end