Code Optimization using <$list/>

Hi,

Any thought to optimize the below scenario using “list” widget?

  1. Setup

    • I’ve 5 tiddlers (say: “Tiddler 01”, “Tiddler 02”, “Tiddler 03”, “Tiddler 04”, “Tiddler 05”, )
    • Another Tiddler called “FinalTiddler” is used to display them one after the other (think steps of some action).
    • I need them in a specific Format (as below)
  2. The below implementation of “FinalTiddler” is working, How to optimize it?

<$let step01="Tiddler 01"
			step02="Tiddler 02"
			step03="Tiddler 03"
			step04="Tiddler 04"
			step05="Tiddler 05"
>

Step 01: <<step01>> ^^<$link to=<<step01>>>Source Tiddler</$link>^^

<$transclude tiddler=<<step01>> />

---
Step 02: <<step02>> ^^<$link to=<<step02>>>Source Tiddler</$link>^^

<$transclude tiddler=<<step02>> />

---
Step 03: <<step03>> ^^<$link to=<<step03>>>Source Tiddler</$link>^^

<$transclude tiddler=<<step03>> />

---
Step 04: <<step04>> ^^<$link to=<<step04>>>Source Tiddler</$link>^^

<$transclude tiddler=<<step04>> />

---
Step 05: <<step05>> ^^<$link to=<<step05>>>Source Tiddler</$link>^^

<$transclude tiddler=<<step05>> />

</$let>

Thanks in Advance

@Mohamed_Amin as soon as you find yourself repeating code in tiddlywiki its time to do something differently.

  • I am not sure what you mean by final tiddler?
<$let steps="[[Tiddler 01]] [[Tiddler 02]] [[Tiddler 03]] [[Tiddler 04]] [[Tiddler 05]]"
>
<$list filter="[<steps>enlist-input[]]">
   Step 0?: <$link/> ^^<$link to=<<currentTiddler>>>Source Tiddler</$link>^^
   <$transclude /><!-- transcludes current tiddler from list -->
   <br>
</$list>
</$let>

Thanks a lot TW_Tones, your solution works like a charm

I just added the “counter” to fill your question mark as following

<$let steps="[[Tiddler 01]] [[Tiddler 02]] [[Tiddler 03]] [[Tiddler 04]] [[Tiddler 05]]"
>
<$list filter="[<steps>enlist-input[]]" counter='cntr'>
   Step 0<<cntr>>: <$link/> ^^<$link to=<<currentTiddler>>>Source Tiddler</$link>^^
   <$transclude /><!-- transcludes current tiddler from list -->
   <br>
</$list>
</$let>

here is the output with some dummy data:

P.S., the final tiddler is just a tiddler which display the other tiddler

2 Likes