Say, I have a tiddler $:/talha131/video/eg1. I want to test if $:/talha131/video/eg1/text exists.
Problem
- If
$:/talha131/video/eg1 is present
- Then check if
$:/talha131/video/eg1/text is present
- If
$:/talha131/video/eg1/text is present then transclude its content
What have I tried?
I am working on a macro.
\define video(src, caption:"")
<$let url= {{{ [<__src__>is[tiddler]get[_canonical_uri]] }}}>
<$let subtitle= {{{ [<__src__>is[tiddler]get[video-subtitle]] }}}>
<$let url= {{{ [<__src__>is[tiddler]get[_canonical_uri]] }}}> works well to check if src is present. If it is, then it reads its _canonical_uri field.
But this syntax does not work, if I want to append a string to the tiddler title, <__src__>/text.

<$let video_text= {{{ [<__src__>/textis[tiddler]get[text]] }}}>

<$let video_text= {{{ [[<__src__>/text]is[tiddler]get[text]] }}}>
What’s the corect syntax to check if a tiddler exists inside a macro?
@talha131 a tiddler exists as soon as it “has a title”, and contains content if it “has text”. So in filters we can say [[tiddlername]has[title]] or [[tiddlername]has[text]]. The has operator needs a value in the field tested.
- If you want to can just ask to get the value
[[tiddlername]get[text]] and if there is no text content, the filter does not return any value.
- However there is the lookup operator as well.
{{{ [[About]lookup[]] }}}
- Using the above depending on how you use it you may need to wikify it
Your <$let url= {{{ [<__src__>is[tiddler]get[_canonical_uri]] }}}> can be simplified to <$let url= {{{ [<__src__>get[_canonical_uri]] }}}>
Rather than use the form<__src__> you can use $src$ eg; {{{ [[$src$]get[_canonical_uri]] }}} which also means you can use [[$src$/text]] but rememebr you also have the addsuffix[/text]] form.
- Sometime we define a macro or set a variable if the text we wish to append clashes with the filer delimiters;
\define text-suffix() /text
\define video(src, caption:"")
... [<__src__>addsuffix<text-suffix>] ...
- You can also use set/let/vars to define text-suffix
I have shown you the filter syntax how to
What’s the correct syntax to check if a tiddler exists inside a macro?
But what do you want to do with the result?
- If it’s the text field perhaps just transclude the tiddler
<$transclude tiddler={{{ [<__src__>addsuffix<text-suffix>] }}}/>
Regards
Tony
The syntax issue in your code is with how to concatenate two strings into one.
<$let video_text= {{{ [<__src__>addsuffix[/text]is[tiddler]get[text]] }}}>
Thank you @TW_Tones and @saqimtiaz. With your help, this is the what I wrote
<$list filter="[<__src__>addsuffix[/text]is[tiddler]]">
<p>
{{$src$/text||$:/talha131/Template/NavigateTranscludedTiddler}}
</p>
</$list>
You can likely simplify as follows since inside the list widget the currentTiddler variable is being set to the tiddler you want to transclude:
<$list filter="[<__src__>addsuffix[/text]is[tiddler]]">
<p>
{{||$:/talha131/Template/NavigateTranscludedTiddler}}
</p>
</$list>