Sha256: b7c64857a67f7e4e2cb228894bc56201f348c2aa26e94b122d24ded01ca8eb67

Contents?: true

Size: 942 Bytes

Versions: 5

Compression:

Stored size: 942 Bytes

Contents

module BootstrapNavbar::Helpers
  def self.included(base)
    raise 'Bootstrap version is not configured.' if BootstrapNavbar.configuration.bootstrap_version.nil?
    helper_version = BootstrapNavbar.configuration.bootstrap_version[0]
    base.send :include, const_get("Bootstrap#{helper_version}")
  end

  def attributes_for_tag(hash)
    string = hash.map { |k, v| %(#{k}="#{v}") }.join(' ')
    if string.length > 0
      ' ' << string
    else
      string
    end
  end

  def current_url?(url)
    normalized_path, normalized_current_path = [url, current_url].map do |url|
      URI.parse(url).path.sub(%r(/\z), '') rescue nil
    end
    normalized_path == normalized_current_path
  end

  def current_url
    raise StandardError, 'current_url_method is not defined.' if BootstrapNavbar.configuration.current_url_method.nil?
    eval BootstrapNavbar.configuration.current_url_method
  end

  def prepare_html(html)
    html
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bootstrap-navbar-1.0.1 lib/bootstrap-navbar/helpers.rb
bootstrap-navbar-1.0.0.pre8 lib/bootstrap-navbar/helpers.rb
bootstrap-navbar-1.0.0.pre7 lib/bootstrap-navbar/helpers.rb
bootstrap-navbar-1.0.0.pre6 lib/bootstrap-navbar/helpers.rb
bootstrap-navbar-1.0.0.pre5 lib/bootstrap-navbar/helpers.rb