Class: TwitterBootstrapBuilder::Builders::NavContainerBuilder

Inherits:
Base
  • Object
show all
Defined in:
lib/twitter_bootstrap_builder/builders/nav_container_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



21
22
23
# File 'lib/twitter_bootstrap_builder/builders/nav_container_builder.rb', line 21

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

#custom(&block) ⇒ Object



33
34
35
# File 'lib/twitter_bootstrap_builder/builders/nav_container_builder.rb', line 33

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

#dividerObject



25
26
27
# File 'lib/twitter_bootstrap_builder/builders/nav_container_builder.rb', line 25

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


29
30
31
# File 'lib/twitter_bootstrap_builder/builders/nav_container_builder.rb', line 29

def dropdown_link(text, &block)
  Tag.block(:li, DropDownLinkBuilder.new(template, text: text, &block).html_safe).to_s.html_safe
end


12
13
14
15
16
17
18
19
# File 'lib/twitter_bootstrap_builder/builders/nav_container_builder.rb', line 12

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
10
# File 'lib/twitter_bootstrap_builder/builders/nav_container_builder.rb', line 5

def to_s
  nav_container = NavContainer.new
  nav_container.pull_right if options[:align] == :right
  nav_container.append template.capture(self, &block) if block
  nav_container.to_s
end