Class: Bridgetown::Slot

Inherits:
Object
  • Object
show all
Includes:
Transformable
Defined in:
lib/bridgetown-core/slot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Transformable

#transform_content, #transform_with_layout

Constructor Details

#initialize(name:, content:, context:, transform: false) ⇒ Slot

Returns a new instance of Slot.



16
17
18
19
20
21
22
# File 'lib/bridgetown-core/slot.rb', line 16

def initialize(name:, content:, context:, transform: false)
  @name, @content, @context = name, content, context

  Bridgetown::Hooks.trigger :slots, :pre_render, self
  transform! if transform
  Bridgetown::Hooks.trigger :slots, :post_render, self
end

Instance Attribute Details

#contentString

Returns:

  • (String)


11
12
13
# File 'lib/bridgetown-core/slot.rb', line 11

def content
  @content
end

#contextObject? (readonly)

Returns:

  • (Object, nil)


14
15
16
# File 'lib/bridgetown-core/slot.rb', line 14

def context
  @context
end

#nameString (readonly)

Returns:

  • (String)


8
9
10
# File 'lib/bridgetown-core/slot.rb', line 8

def name
  @name
end

Instance Method Details

#transform!Object



24
25
26
# File 'lib/bridgetown-core/slot.rb', line 24

def transform!
  self.content = transform_content(context, alternate_content: content)
end