mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-11 18:50:28 +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
|
||||
|
||||
<!-- 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()
|
||||
<span class="tc-toc-caption tc-tiny-gap-left" title={{{ [{!!toc-tooltip}!is[blank]] :else[<currentTiddler>] }}}>
|
||||
<$let tv-wikilinks="no">
|
||||
<$transclude $tiddler={{{ [<itemTemplate>!is[blank]then<itemTemplate>else<currentTiddler>] }}}
|
||||
$field={{{ [<itemTemplate>!is[blank]then[text]]
|
||||
:else[<captionField>!is[blank]then<captionField>] }}}
|
||||
<$let tv-wikilinks="no"
|
||||
field={{{ [<currentTiddler>] :cascade[<_hasItemTemplate>append<_hasCaptionField>append<_hasCaption>append[title]] }}}
|
||||
>
|
||||
<span class="tc-tiny-gap-left"
|
||||
data-fieldClass=`field-$(field)$`
|
||||
title={{{ [{!!toc-tooltip}!is[blank]] :else[<currentTiddler>] }}}
|
||||
>
|
||||
<$transclude $field={{{ [{!!caption}!is[blank]then[caption]else[title]] }}}>
|
||||
<$view field="title"/>
|
||||
</$transclude>
|
||||
</$transclude>
|
||||
<$log/>
|
||||
<$transclude $field=<<field>>/>
|
||||
</span>
|
||||
</$let>
|
||||
</span>
|
||||
\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()
|
||||
<$transclude $tiddler=<<tf.toc-getItemTemplateTitle>> >
|
||||
<<toc-defaultItemTemplate>>
|
||||
|
Loading…
Reference in New Issue
Block a user