Conditional macro: transclusion or tiddler creation button/link

89 views
Skip to first unread message

Cade Roux

unread,
Aug 27, 2019, 4:30:17 PM8/27/19
to TiddlyWiki
Where I want tiddlers to be transcluded if they exist and a button to create the tiddler if they don't exist in my table.

\define conditionaltiddler(title : "Tiddler Title")
<$set name="btn">
<$button class="tc-btn-invisible tc-tiddlylink">
<$action-createtiddler $basetitle="$title$" />
Create Tiddler: $title$
</$button>
</$set>
<$list filter="[$title$]" emptyMessage="$btn$">{{$title$}}</$list>
\end

|Value|Description|h
|Absent|<<conditionaltiddler title:"Observation-Regurgitation-Absent">>|
|Mild|<<conditionaltiddler title:"Observation-Regurgitation-Mild">>|
|Mild to moderate|<<conditionaltiddler title:"Observation-Regurgitation-Mild to moderate">>|

|Value|Description|h
|Absent|{{Observation-Regurgitation-Absent}}|
|Mild|<$button class="tc-btn-invisible tc-tiddlylink"><$action-createtiddler $basetitle="Observation-Regurgitation-Mild" />Create Tiddler: Observation-Regurgitation-Mild</$button>|
|Mild to moderate|{{Observation-Regurgitation-Mild to moderate}}|

The bottom table is what I want it to look like, the top is my attempt so far.  The transclusion part is working fine.  I made a variable to hold the button and put that in the empty message, but it's showing up all the time.  I feel like I have a little while to go before I grok the macro/filter/widget system.

Capture.PNG


Thanks in advance,


Cade


Eric Shulman

unread,
Aug 27, 2019, 5:08:32 PM8/27/19
to TiddlyWiki
On Tuesday, August 27, 2019 at 1:30:17 PM UTC-7, Cade Roux wrote:
Where I want tiddlers to be transcluded if they exist and a button to create the tiddler if they don't exist in my table.

try this:

\define btn(title)

<$button class="tc-btn-invisible tc-tiddlylink">
<$action-createtiddler $basetitle="$title$" />
Create Tiddler: $title$
<
/$button>
\end

\define conditionaltiddler(title)
<$list filter="[$title$]" emptyMessage=<<btn>>>{{$title$}}</
$list>
\end

enjoy,
-e
Eric Shulman
TiddlyTools: "Small Tools for Big Ideas!" (tm) http://tiddlytools.github.io (TWClassic)
InsideTiddlyWiki: The Missing Manuals

Cade Roux

unread,
Aug 27, 2019, 5:21:19 PM8/27/19
to TiddlyWiki

I think I follow what you are doing, but now it's not putting out the button link at all.  Is there any kind of debug mode so you can see all the processing steps before rendering?


Capture.PNG

Cade Roux

unread,
Aug 27, 2019, 5:39:00 PM8/27/19
to TiddlyWiki
After fooling with it and altering the filter and adding some features, I got it - thanks for the point in the right direction!

\define btn(title)
<$button class="tc-btn-invisible tc-tiddlylink">
<$action-createtiddler $basetitle="$title$" />
<$action-navigate $to="$title$" $scroll="yes"/>
Missing: $title$
</$button>
\end

Capture.PNG



\define conditionaltiddler(title)
<$list filter="[title[$title$]] +[has[title]]" emptyMessage=<<btn """$title$""">>>{{$title$}} ([[Edit|$title$]])</$list>
\end

Eric Shulman

unread,
Aug 27, 2019, 5:41:35 PM8/27/19
to TiddlyWiki

On Tuesday, August 27, 2019 at 2:21:19 PM UTC-7, Cade Roux wrote:

I think I follow what you are doing, but now it's not putting out the button link at all.  Is there any kind of debug mode so you can see all the processing steps before rendering?



oops.... I forgot to pass the $title$ value on to the button macro....
also, because of the way filters are parsed, your filter "[$title$]" will never be "empty"...

try this:

<$list filter="[[$title$]is[tiddler]]" emptyMessage=<<btn """$title$""">>>{{$title$}}</$list>


-e


Cade Roux

unread,
Aug 27, 2019, 6:04:28 PM8/27/19
to TiddlyWiki
Yep, I think that's basically what I discovered about the filter but it was masked and only uncovered when I started to add the edit link for what was supposed to be existing tiddlers

Thanks again,

Cade
Reply all
Reply to author
Forward
0 new messages