Module: BulmaX::Dsl::Slots
- Defined in:
- lib/bulma_x/dsl/slots.rb
Defined Under Namespace
Modules: ClassMethods, DeferredRender
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.included(base) ⇒ Object
119
120
121
|
# File 'lib/bulma_x/dsl/slots.rb', line 119
def self.included(base)
base.extend(ClassMethods)
end
|
Instance Method Details
#content(slot_name) ⇒ Object
content is used to store a slot content for later use (via slot or slots) It is meant to be used during the render context :
render Component.new { it.content(:slot_name) { 'My slot content' } }
131
132
133
134
135
136
137
138
|
# File 'lib/bulma_x/dsl/slots.rb', line 131
def content(slot_name, **, &)
if respond_to?(:"with_#{slot_name}", true)
send(:"with_#{slot_name}", **, &)
else
raise ArgumentError,
"Content was called for slot `#{slot_name}`, but this slot does not exist on #{self.class}"
end
end
|
#initialize ⇒ Object
123
124
125
126
|
# File 'lib/bulma_x/dsl/slots.rb', line 123
def initialize(...)
super
@slots = {}
end
|
#slot?(slot_name, idx = 0) ⇒ Boolean
Also known as:
content?
140
141
142
143
144
145
146
|
# File 'lib/bulma_x/dsl/slots.rb', line 140
def slot?(slot_name, idx = 0)
if @slots[slot_name].is_a?(Enumerable)
@slots[slot_name].size > idx
else
@slots.key?(slot_name)
end
end
|