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

dom_id_nested

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dom_id_nested

  • 1.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

DomIdNested

DomIdNested is a Ruby on Rails gem that extends the functionality of the built-in dom_id helper, making it more versatile by allowing it to work with a combination of ActiveRecord models and custom strings.

Installation

Add this line to your application's Gemfile:

gem "dom_id_nested"

And then execute:

$ bundle install

Usage

With DomIdNested, you can easily generate DOM IDs by passing a combination of ActiveRecord models and custom strings to the dom_id helper. Here’s an example:

user = User.find(1)

dom_id(user, "edit_button") #=> "user_1_edit_button"

You can also pass multiple ActiveRecord models and strings as arguments:

post = Post.find(1)
comment = Comment.find(2)

dom_id(user, post, comment, "content") #=> "user_1_post_1_comment_2_content"

The gem will automatically omit any blank records passed:

dom_id(user, nil, "", "edit_button") #=> "user_1_edit_button"

If all records are blank, the dom_id helper will return nil:

dom_id(nil, "") #=> nil

License

The gem is available as open source under the terms of the MIT License » https://opensource.org/licenses/MIT.

FAQs

Package last updated on 13 May 2023

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