
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
custom_elements-rails
Advanced tools
This gem adds a simple way to automatically register custom elements in your importmap-rails
app. No build step required!
Add this line to your application's Gemfile:
gem "custom_elements-rails"
Install the gem:
$ bundle install
Run the initial setup:
$ rails custom_elements:install
This will setup and edit add the following files:
app/javascript
├── application.js
└── custom_elements
├── hello_element.js
└── index.js
The <app-hello>
custom element can be used in the views now.
You can generate a new custom element with rails g custom_element abc
.
The setup will add a JS function call eagerDefineCustomElementsFrom
that parses the importmap rendered by the importmap-rails
gem.
It registers custom elements with customElements.define(...)
in the browser's registry based on the filenames in the custom_elements
folder automatically.
custom_elements/hello_element.js // will register <app-hello> automatically
Your *_element.js
files have to export default
custom elements for this to work properly.
[!WARNING]
Only single word elements are supported currently. See https://github.com/codergeek121/custom_elements-rails/issues/1
This gem adds a generator to generate new custom elements with:
$ rails generate custom_element test
This will generate
// app/javascript/custom_elements/test_element.js
export default class extends HTMLElement {
constructor() {
super()
}
connectedCallback() {
console.log("test_element.js")
}
}
which in turn will register a <app-test></app-test>
custom element automatically in your app.
$ rails generate custom_element test
To observe changes in your custom element's attributes, you need to set a static array of attribute names. The generator also supports setting those automatically:
$ rails generate custom_element test attribute1
will generate
export default class extends HTMLElement {
static observedAttributes = ["attribute1"]
constructor() {
super()
}
connectedCallback() {
console.log("test_element.js")
}
get attribute1() {
return this.getAttribute("attribute1")
}
}
eagerDefineCustomElementsFrom(under, options)
Currently supported options
:
prefix
: The custom elements namespace/prefix.TODO
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that custom_elements-rails demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.