GithubHelp home page GithubHelp logo

aditya01933 / bootstrap-navbar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bootstrap-ruby/bootstrap-navbar

0.0 1.0 0.0 1.29 MB

Helpers to generate a Twitter Bootstrap navbar

Home Page: http://krautcomputing.github.io/bootstrap-navbar/

License: MIT License

Ruby 100.00%

bootstrap-navbar's Introduction

BootstrapNavbar

Gem Version Build Status Dependency Status Code Climate

Helpers to generate a Twitter Bootstrap style navbar

Installation

This gem only provides a helper module with methods to generate HTML. It can be used by other gems to make these helpers available to a framework's rendering engine, e.g.:

In short: Unless you know what you're doing, do not use this gem directly in your app!

Requirements

Only Bootstrap >= 2.1.0 is supported. It might work with earlier versions as well though.

Setup

Set bootstrap_version (required)

BootstrapNavbar needs to know what version of Bootstrap it's dealing with since each version has small changes compared to the previous one.

BootstrapNavbar.configure do |config|
  config.bootstrap_version = '3.0.0'
end

Set current_url_method (required)

BootstrapNavbar has to be able to query for the current URL when rendering the navbar, e.g. to determine if a menu item is active or not. Since the way the current URL is determined varies depending on whether you use Rails, Sinatra, etc., this has to be set beforehand in some kind of initializer:

# For Rails >= 3.2
BootstrapNavbar.configure do |config|
  config.current_url_method = 'request.original_url'
end

current_url_method should be set to a string which can be evaled later.

Set up HTML escaping (optional)

If the framework or rendering engine that you use BootstrapNavbar with escapes HTML by default, you can instruct BootstrapNavbar to mark the returned HTML as html_safe by default by overriding BootstrapNavbar#prepare_html:

# For Rails
module BootstrapNavbar::Helpers
  def prepare_html(html)
    html.html_safe
  end
end

Mix in the helpers into the rendering engine (required)

# For Rails
ActionView::Base.send :include, BootstrapNavbar::Helpers

Usage

Since the navbar format changed quite a bit between Bootstrap 2.x and 3.x, generating them using this gem is quite different as well. Check out the Wiki pages for detailed instructions:

Usage with Bootstrap 2.x

Usage with Bootstrap 3.x

Changes

See CHANGELOG

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

bootstrap-navbar's People

Contributors

manuelmeurer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.