Sha256: b57d4aaba716349ebd269b50cee7d805619c065a93834c63d79cd3e35e678e72

Contents?: true

Size: 1001 Bytes

Versions: 2

Compression:

Stored size: 1001 Bytes

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).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)).html_safe
        end
      end

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

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

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

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twitter_bootstrap_builder-0.0.6 lib/twitter_bootstrap_builder/builders/nav_list_builder.rb
twitter_bootstrap_builder-0.0.5 lib/twitter_bootstrap_builder/builders/nav_list_builder.rb