Macro with conditional output

72 views
Skip to first unread message

Laurent Bonet

unread,
Jul 28, 2018, 12:00:04 PM7/28/18
to TiddlyWiki
Question from a newbie:

I would like to write a macro that return:
- the "caption" field of a tiddler if this field has a value
- the title of the tiddler if this tiddler doesnt have a caption field

Thx in advance for your help.

Rgds

Eric Shulman

unread,
Jul 28, 2018, 1:50:16 PM7/28/18
to TiddlyWiki
On Saturday, July 28, 2018 at 9:00:04 AM UTC-7, Laurent Bonet wrote:
I would like to write a macro that return:
- the "caption" field of a tiddler if this field has a value
- the title of the tiddler if this tiddler doesnt have a caption field


As per documentation:
"The content of the <$view> widget is displayed if the field or property is missing or empty."

Thus:
<$view field="caption">
   <$view field="title"></$view>
</$view>

enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas!" (tm)
InsideTiddlyWiki: The Missing Manuals

Laurent Bonet

unread,
Jul 29, 2018, 4:53:15 AM7/29/18
to TiddlyWiki
Thx very much for your help Eric !
Reply all
Reply to author
Forward
0 new messages