Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.