Sha256: 12e855368e4cdaa767937dd08ad98c2fe81c586c091d8fedaee1e7dead4fd008

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

module TwitterBootstrapBuilder
  module Builders
    class NavListBuilder < Base

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

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

      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

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

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

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

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twitter_bootstrap_builder-0.0.4 lib/twitter_bootstrap_builder/builders/nav_list_builder.rb
twitter_bootstrap_builder-0.0.3 lib/twitter_bootstrap_builder/builders/nav_list_builder.rb