Class: Bridgetown::Slot

Inherits:
Object
  • Object
show all
Includes:
Transformable
Defined in:
bridgetown-core/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.



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

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)


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

def content
  @content
end

#contextObject? (readonly)

Returns:

  • (Object, nil)


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

def context
  @context
end

#nameString (readonly)

Returns:

  • (String)


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

def name
  @name
end

Instance Method Details

#transform!Object



26
27
28
# File 'bridgetown-core/lib/bridgetown-core/slot.rb', line 26

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