Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Cedar allows you to render view_component without a sidecar template. It leverages ActiveAdmin's arbre to provide a pure ruby DSL for creating markup. In addition Cedar provides convenience methods for rendering components and component collections.
Add this line to your application's Gemfile:
gem 'cedar-component'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install cedar
To use Cedar, you need to extend your components with Cedar::Component
. The most straight forward way to do this is right
in your base ApplicationComponent
class.
class ApplicationComponent < ViewComponent::Base
extend Cedar::Component
end
Cedar
provides 3 key pieces of functionality:
render
is now available to you as a class level method, which renders the contained arbre
tree.
class FoobarComponent < ApplicationComponent
render do
div do
para "Wow this is kind of neat"
end
end
end
We provide a shortcut for rendering components themselves. If you have a component called MyCoolButtonComponent
, you can render this by simply calling my_cool_button
within your arbre tree.
class FoobarComponent < ApplicationComponent
class MyCoolButtonComponent < ApplicationComponent
def initialize(label:)
@label = label
end
render { button_tag "Click me!", class: "btn btn-primary" }
end
render do
div do
para "We're going to render our cool button below"
my_cool_button label: "Click me!"
end
end
end
Suffixing your component tag with _collection
will render a collection of your components.
class FoobarComponent < ApplicationComponent
class MyCoolButtonComponent < ApplicationComponent
with_collection_param :label
def initialize(label:)
@label = label
end
render { button_tag "Click me!", class: "btn btn-primary" }
end
render do
my_cool_button_collection %w[One Two Three Four]
end
end
If you need to access the underlying rails helpers instead of the arbre helpers, use the helpers
object.
For example, if you were making a compatible wrapper around label
:
class LabelComponenent < ApplicationComponent
def initialize(object_name, method, text = nil, options = {})
@object_name = object_name
@method = method
@text = text
@options = options
@options[:class] ||= "label"
end
render do
helpers.label @object_name, @method, @text, @options
end
end
FAQs
Unknown package
We found that cedar-component 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.