README.md in navigator-1.0.0 vs README.md in navigator-1.1.0

- old
+ new

@@ -12,12 +12,35 @@ # Features - Provides a simple DSL for building navigation menus. - Supports auto-detection/highlighting of active menu items based on current path (customizable for non-path usage too). - Supports sub-menus, nested tags, HTML attributes, etc. -- Supports the following HTML tags: nav, section, h1-h6, ul, li, a, b, em, s, small, span, strong, sub, and sup. -- Provides an "item" convenience method which combines the "li" and "a" HTML tags into a single method for less typing. +- Supports the following HTML tags: + - div + - section + - header + - h1 - h6 + - nav + - ul + - li + - a + - img + - b + - em + - s + - small + - span + - strong + - sub + - sup + - form + - label + - select + - option + - input + - button +- Provides `link`, `image`, and `item` convenience methods for succinct ways to build commonly used menu elements. # Requirements 0. Any of the following Ruby VMs: - [MRI 2.x.x](http://www.ruby-lang.org) @@ -195,19 +218,65 @@ <li><a href="/admin/users">Users</a></li> </ul> </li> </ul> +## Menu Helpers + +There are several convenience methods, in addition to the standard HTML tags, that can make for shorter lines of code. +The following describes each: + +When building links, the default is: + + navigation "nav", activator: activator do + a "Home", attributes: {href: home_path} + end + +...but can be written as: + + navigation "nav", activator: activator do + link "Home", home_path + end + +When building images, the default is: + + navigation "nav", activator: activator do + img attributes: {src: "http://placehold.it/50x50", alt: "Example"} + end + +...but can be written as: + + navigation "nav", activator: activator do + image "http://placehold.it/50x50", "Example" + end + +When building menu items, the default is: + + navigation "nav", activator: activator do + li do + a "Home", attributes: {href: home_path} + end + end + +...but can be written as: + + navigation "nav", activator: activator do + item "Home", "/dashboard" + end + +These are just a few, simple, examples of what can be achieved. See the specs for additional usage and customization. + # Customization The `navigation` view helper can accept an optional `Navigator::TagActivator` instance. Example: # Code activator = Navigator::TagActivator.new search_value: request.env["PATH_INFO"] + navigation "nav", activator: activator do - a "Home", attributes: {href: home_path} - a "About", attributes: {href: about_path} + link "Home", home_path + link "About", about_path end <!-- Result --> <nav> <a href="/home" class="active">Home</a> @@ -235,12 +304,12 @@ search_value: "123", target_key: "data-style" target_value: "current" navigation "nav", activator: activator do - a "Home", attributes: {href: home_path, "data-id" => "123", data-style="info"} - a "About", attributes: {href: about_path, "data-id" => "789"} + link "Home", home_path, attributes: {data: {id: "123", data-style="info"}} + link "About", about_path attributes: {data: {id: "789"}} end <!-- Result --> <nav> <a href="/home" data-id="123" data-style="info current">Home</a> @@ -264,22 +333,27 @@ - Patch (x.y.Z) - Incremented for small, backwards compatible bug fixes. - Minor (x.Y.z) - Incremented for new, backwards compatible public API enhancements and/or bug fixes. - Major (X.y.z) - Incremented for any backwards incompatible public API changes. +# Code of Conduct + +Please note that this project is released with a [CODE OF CONDUCT](CODE_OF_CONDUCT.md). By participating in this project +you agree to abide by its terms. + # Contributions Read [CONTRIBUTING](CONTRIBUTING.md) for details. -# Credits - -Developed by [Brooke Kuhlmann](https://www.alchemists.io) at [Alchemists](https://www.alchemists.io) - # License Copyright (c) 2012 [Alchemists](https://www.alchemists.io). Read the [LICENSE](LICENSE.md) for details. # History Read the [CHANGELOG](CHANGELOG.md) for details. Built with [Gemsmith](https://github.com/bkuhlmann/gemsmith). + +# Credits + +Developed by [Brooke Kuhlmann](https://www.alchemists.io) at [Alchemists](https://www.alchemists.io).