This page is part of a static HTML representation of the TiddlyWiki at https://tiddlywiki.com/

SlotWidget

 11th May 2023 at 12:39pm

Introduction

New in v5.3.0 The $slot widget is used within transcluded content to mark "slots" that the transcluding widget can fill with the $fill widget.

See the $transclude widget for details.

Attributes

The content of the $slot widget is used as a fallback for the slot content if the corresponding $fill widget is not found.

AttributeDescription
$nameThe name of the slot being defined
$depthOptional number indicating how deep the $slot widget is compared to the matching $fill widget as measured by the number of nested transclude widgets (defaults to 1). Transclude widgets whose $fillignore attribute is set to yes are ignored, and do not affect the depth count

Examples

Quoted content

When content contains quotes, passing it through attributes and parameters can be challenging. However, passing the content using the $fill widget content eliminates the need to wrap it in quotes, making the process easier.

If a variable named bold_slot contains the following $slot definition:

<b>
<$slot $name="body"/>
</b>

then the slot can be filled using this variable transclusion:

<$transclude $variable=bold_slot>
<$fill $name=body>

"""
some text
using [[Hard Linebreaks in WikiText]]
syntax
"""
</$fill>
</$transclude>

That renders as:

some text
using Hard Linebreaks in WikiText
syntax

Depth

If a variable named table_slot contains the following $slot definition:

|!depth|!slot1|!slot2|
|1|<$slot $name=slot1/>|<$slot $name=slot2/>|
|2|<$slot $name=slot1 $depth=2>missing</$slot>|<$slot $name=slot2 $depth=2>missing</$slot>|

then the slot values can be filled at different transclusion depths:

<$transclude $variable=table_slot  $mode=block>
  <$fill $name=slot1>outer1</$fill>
  <$fill $name=slot2>outer2
    <$transclude $variable=table_slot $mode=block>
      <$fill $name=slot1>inner1</$fill>
      <$fill $name=slot2>inner2</$fill>
    </$transclude>
  </$fill>
</$transclude>

That renders as:

depthslot1slot2
1outer1outer2
depthslot1slot2
1inner1inner2
2outer1outer2
depthslot1slot2
1inner1inner2
2inner1inner2
2missingmissing

The slot1 slot is filled at both depths with a simple string (outer1 and outer2). For slot2, the outer instance is a simple string but the inner instance recursively transcludes the same table_slot variable again. The recursion ends at the third transclusion call since both "inner" slots are filled with simple strings.