From 63fc0bc562f2b608e96d9fa54eaa2f1f00b5f2de Mon Sep 17 00:00:00 2001 From: pmario Date: Mon, 13 May 2024 12:58:04 +0200 Subject: [PATCH] add cascade to check if macro prams and fields are valid. eg Caption has a value --- core/wiki/macros/toc.tid | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/core/wiki/macros/toc.tid b/core/wiki/macros/toc.tid index f99d9523a..ca5df085b 100644 --- a/core/wiki/macros/toc.tid +++ b/core/wiki/macros/toc.tid @@ -17,26 +17,31 @@ The very first toc macro is _not_ reused. So it can be used as a simple referenc \whitespace trim + +\procedure _hasItemTemplate() [!is[blank]then[text]] +\procedure _hasCaptionField() [get!is[blank]then] +\procedure _hasCaption() [has[caption]then[caption]] + + \procedure toc-defaultItemTemplate() -] }}}> -<$let tv-wikilinks="no"> - <$transclude $tiddler={{{ [!is[blank]thenelse] }}} - $field={{{ [!is[blank]then[text]] - :else[!is[blank]then] }}} +<$let tv-wikilinks="no" + field={{{ [] :cascade[<_hasItemTemplate>append<_hasCaptionField>append<_hasCaption>append[title]] }}} +> + ] }}} > - <$transclude $field={{{ [{!!caption}!is[blank]then[caption]else[title]] }}}> - <$view field="title"/> - - - <$log/> + <$transclude $field=<>/> + - \end - -\function tf.toc-getItemTemplateTitle() [!is[blank]then] :else[get[toc-itemTemplate]] + +\function tf.toc-getItemTemplateTitle() [get[toc-itemTemplate]] :filter[has[text]] :else[has[text]then] - \procedure _itemTemplate() <$transclude $tiddler=<> > <>