Sha256: 4f620d379caee28a528d2d1ca3e4a529bbec78e8b29b7b1b17188eabad5581cf

Contents?: true

Size: 960 Bytes

Versions: 2

Compression:

Stored size: 960 Bytes

Contents

module Tabit
  class Builder
    include ActionView::Helpers::TagHelper
    include ActionView::Helpers::CaptureHelper

    attr_accessor :output_buffer
    attr_accessor :template

    def initialize(template)
      @template = template
    end

    def add(name, url = nil, options = {})
      options[:inner] ||= {}
      options[:outer] ||= {}

      options[:active] ||= configuration.active_detect
      url ||= '#'

      clazz = template.active_link_to_class(
        url,
        {
          :active => options[:active],
          :class_active => configuration.active_class
        }
      )

      options[:outer][:class] = '' if options[:outer][:class].nil?
      options[:outer][:class] << " #{clazz}"
      options[:outer][:class].strip!

      content_tag(:li, name, options[:outer]) do
        template.link_to name, url, options[:inner]
      end
    end

    protected
      def configuration
        Tabit.configuration
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tabit-0.1.2 lib/tabit/builder.rb
tabit-0.1.1 lib/tabit/builder.rb