mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-20 22:16:52 +00:00
add cascade to check if macro prams and fields are valid. eg Caption has a value
This commit is contained in:
parent
21981776a9
commit
63fc0bc562
@ -17,26 +17,31 @@ The very first toc macro is _not_ reused. So it can be used as a simple referenc
|
|||||||
|
|
||||||
\whitespace trim
|
\whitespace trim
|
||||||
|
|
||||||
|
<!-- The field to show depends on the following cascade - default: title -->
|
||||||
|
\procedure _hasItemTemplate() [<itemTemplate>!is[blank]then[text]]
|
||||||
|
\procedure _hasCaptionField() [get<captionField>!is[blank]then<captionField>]
|
||||||
|
\procedure _hasCaption() [has[caption]then[caption]]
|
||||||
|
|
||||||
|
<!-- Use this item template as a default -->
|
||||||
\procedure toc-defaultItemTemplate()
|
\procedure toc-defaultItemTemplate()
|
||||||
<span class="tc-toc-caption tc-tiny-gap-left" title={{{ [{!!toc-tooltip}!is[blank]] :else[<currentTiddler>] }}}>
|
<$let tv-wikilinks="no"
|
||||||
<$let tv-wikilinks="no">
|
field={{{ [<currentTiddler>] :cascade[<_hasItemTemplate>append<_hasCaptionField>append<_hasCaption>append[title]] }}}
|
||||||
<$transclude $tiddler={{{ [<itemTemplate>!is[blank]then<itemTemplate>else<currentTiddler>] }}}
|
>
|
||||||
$field={{{ [<itemTemplate>!is[blank]then[text]]
|
<span class="tc-tiny-gap-left"
|
||||||
:else[<captionField>!is[blank]then<captionField>] }}}
|
data-fieldClass=`field-$(field)$`
|
||||||
|
title={{{ [{!!toc-tooltip}!is[blank]] :else[<currentTiddler>] }}}
|
||||||
>
|
>
|
||||||
<$transclude $field={{{ [{!!caption}!is[blank]then[caption]else[title]] }}}>
|
<$transclude $field=<<field>>/>
|
||||||
<$view field="title"/>
|
</span>
|
||||||
</$transclude>
|
|
||||||
</$transclude>
|
|
||||||
<$log/>
|
|
||||||
</$let>
|
</$let>
|
||||||
</span>
|
|
||||||
\end
|
\end
|
||||||
|
|
||||||
<!-- Returns the title of a tiddler -->
|
<!--
|
||||||
\function tf.toc-getItemTemplateTitle() [<itemTemplate>!is[blank]then<itemTemplate>] :else[<currentTiddler>get[toc-itemTemplate]]
|
Check if a user defined item template should be used.
|
||||||
|
It can be a macro parameter: itemTemplate or a tiddler field: toc-itemTemplate.
|
||||||
|
-->
|
||||||
|
\function tf.toc-getItemTemplateTitle() [<currentTiddler>get[toc-itemTemplate]] :filter[has[text]] :else[<itemTemplate>has[text]then<itemTemplate>]
|
||||||
|
|
||||||
<!-- Use macro itemTemplate or one defined as a toc-itemTemplate field -->
|
|
||||||
\procedure _itemTemplate()
|
\procedure _itemTemplate()
|
||||||
<$transclude $tiddler=<<tf.toc-getItemTemplateTitle>> >
|
<$transclude $tiddler=<<tf.toc-getItemTemplateTitle>> >
|
||||||
<<toc-defaultItemTemplate>>
|
<<toc-defaultItemTemplate>>
|
||||||
|
Loading…
Reference in New Issue
Block a user