Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

partial_menu

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

partial_menu

  • 1.2.3
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Gem Version

PartialMenu

Generating hierarchical menus in Rails should utilize Rails' built-in partial views instead of using some kind on HTML code generators. This gem just do that.

Usage

After installing the gem you can generate the views and the config file to create your own menus, even more than one can be generated by using name prefixes.

rails generate partial_menu:yaml

This will generate an example menu description yaml file in config/main_menu.yaml

You can have multiple menu definitiions in an app. For this you can use the --type parameter to set the name of the file

rails generate partial_menu:yaml -t side

This will create config/side_menu.yaml

You can define your menu structure in the generated yaml file:

---
menu:                                   # Marks the beginnin of the menu
  - first_item:                         # Adds a menu item. Text here will be parsed as id for the item.
    title: "First item"                 # Optional title of the item. If not set, ID will be used
    uri: root                           # Optional URI, in any format url_for would parse
    icon: test                          # Optional icon for the item.
  - second_item: separator              # A second menu item, specifing that its just a separator.
  - third_item:
    icontype: glyph                     # You can add any arbitarty property to an item, it will be parsed and can be used in templates.
    menu:                               # Here comes the submenu
    - first_submenu: link               # First submenu, with specifing its link as a shortcut.
    - second_submenu:
      title: menu.second_submenu.title  # You can use any text as title. In your template you can use it as you whish, like translate it with I18N::t()
      uri: second

Customizing views:

    rails generate partial_menu:views -d side

This will create:

  • app/views/side_menu/_menu.html.erb -- menu root template
  • app/views/side_menu/_item.html.erb -- menu items template
  • app/views/side_menu/_separator.html.erb -- separator template
  • app/views/side_menu/_submenu_item.html.erb -- submenu root template
  • app/views/side_menu/_item.html.erb -- submenu items template

Installation

Add this line to your application's Gemfile:

gem 'partial_menu'

And then execute:

$ bundle

Or install it yourself as:

$ gem install partial_menu

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 02 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc