What is the most elegant way to code in a macro if a param exists use it here...otherwise a result produced by a filter

…as I already said in the very long title :wink:
For example if I take this qr-code macro

\define qr(text,caption)
<center>

!"""$caption$"""
<center><img src=<<makeqr text:"""$text$""" size:"400">>/><br>
$text$
</center>
\end

How to use caption instead of text and if no caption is defined text elegantly?

\define qr(text,caption)
<center>

!"""$caption$"""
<center><img src=<<makeqr text:"""$text$""" size:"400">>/><br>

<a href="$text$"><$list filter="[[$caption$]!match[]else[$text$]]">{{!!title}}</$list></a>

</center>
\end

Like this?

[[$caption$]!is[blank]then[$caption$]else[$text$]]

I think you care about “contains something”, not “existence”.

1 Like