Class: PhlexKit::BubbleContent
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::BubbleContent
- Defined in:
- app/components/phlex_kit/bubble/bubble_content.rb
Constant Summary collapse
- AS_TAGS =
as:is dispatched dynamically — whitelist the sensible text containers so it can't reach arbitrary (including private) methods. %i[div p blockquote].freeze
Instance Method Summary collapse
-
#initialize(as: :div, **attrs) ⇒ BubbleContent
constructor
A new instance of BubbleContent.
- #view_template ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(as: :div, **attrs) ⇒ BubbleContent
Returns a new instance of BubbleContent.
6 7 8 9 10 |
# File 'app/components/phlex_kit/bubble/bubble_content.rb', line 6 def initialize(as: :div, **attrs) @as = as.to_sym raise ArgumentError, "unknown BubbleContent as: #{@as.inspect} (use one of #{AS_TAGS.join(", ")})" unless AS_TAGS.include?(@as) @attrs = attrs end |
Instance Method Details
#view_template ⇒ Object
11 12 13 |
# File 'app/components/phlex_kit/bubble/bubble_content.rb', line 11 def view_template(&) send(@as, **mix({ class: "pk-bubble-content", data: { slot: "bubble-content" } }, @attrs), &) end |