mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-05-13 12:54:07 +00:00
Tree macro: allow separator to be customised
This commit is contained in:
parent
23dd8da22c
commit
fc09f8e331
@ -1,7 +1,7 @@
|
|||||||
title: $:/core/macros/tree
|
title: $:/core/macros/tree
|
||||||
tags: $:/tags/Macro
|
tags: $:/tags/Macro
|
||||||
|
|
||||||
\define leaf-link(full-title, chunk)
|
\define leaf-link(full-title,chunk,separator: "/")
|
||||||
<$link to=<<__full-title__>>><$text text=<<__chunk__>>/></$link>
|
<$link to=<<__full-title__>>><$text text=<<__chunk__>>/></$link>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ tags: $:/tags/Macro
|
|||||||
</li>
|
</li>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
\define branch-node(prefix, chunk)
|
\define branch-node(prefix,chunk,separator: "/")
|
||||||
<li>
|
<li>
|
||||||
<$set name="reveal-state" value={{{ [[$:/state/tree/]addsuffix<__prefix__>addsuffix<__chunk__>] }}}>
|
<$set name="reveal-state" value={{{ [[$:/state/tree/]addsuffix<__prefix__>addsuffix<__chunk__>] }}}>
|
||||||
<$reveal type="nomatch" stateTitle=<<reveal-state>> text="show">
|
<$reveal type="nomatch" stateTitle=<<reveal-state>> text="show">
|
||||||
@ -30,28 +30,28 @@ tags: $:/tags/Macro
|
|||||||
</$reveal>
|
</$reveal>
|
||||||
<span>(<$count filter="[all[shadows+tiddlers]removeprefix<__prefix__>removeprefix<__chunk__>] -[<__prefix__>addsuffix<__chunk__>]"/>)</span>
|
<span>(<$count filter="[all[shadows+tiddlers]removeprefix<__prefix__>removeprefix<__chunk__>] -[<__prefix__>addsuffix<__chunk__>]"/>)</span>
|
||||||
<$reveal type="match" stateTitle=<<reveal-state>> text="show">
|
<$reveal type="match" stateTitle=<<reveal-state>> text="show">
|
||||||
<$macrocall $name="tree-node" prefix={{{ [<__prefix__>addsuffix<__chunk__>] }}}/>
|
<$macrocall $name="tree-node" prefix={{{ [<__prefix__>addsuffix<__chunk__>] }}} separator=<<__separator__>>/>
|
||||||
</$reveal>
|
</$reveal>
|
||||||
</$set>
|
</$set>
|
||||||
</li>
|
</li>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
\define tree-node(prefix)
|
\define tree-node(prefix,separator: "/")
|
||||||
<ol>
|
<ol>
|
||||||
<$list filter="[all[shadows+tiddlers]removeprefix<__prefix__>splitbefore[/]sort[]!suffix[/]]" variable="chunk">
|
<$list filter="[all[shadows+tiddlers]removeprefix<__prefix__>splitbefore<__separator__>sort[]!suffix<__separator__>]" variable="chunk">
|
||||||
<$macrocall $name="leaf-node" prefix=<<__prefix__>> chunk=<<chunk>>/>
|
<$macrocall $name="leaf-node" prefix=<<__prefix__>> chunk=<<chunk>> separator=<<__separator__>>/>
|
||||||
</$list>
|
</$list>
|
||||||
<$list filter="[all[shadows+tiddlers]removeprefix<__prefix__>splitbefore[/]sort[]suffix[/]]" variable="chunk">
|
<$list filter="[all[shadows+tiddlers]removeprefix<__prefix__>splitbefore<__separator__>sort[]suffix<__separator__>]" variable="chunk">
|
||||||
<$macrocall $name="branch-node" prefix=<<__prefix__>> chunk=<<chunk>>/>
|
<$macrocall $name="branch-node" prefix=<<__prefix__>> chunk=<<chunk>> separator=<<__separator__>>/>
|
||||||
</$list>
|
</$list>
|
||||||
</ol>
|
</ol>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
\define tree(prefix: "$:/")
|
\define tree(prefix: "$:/",separator: "/")
|
||||||
<div class="tc-tree">
|
<div class="tc-tree">
|
||||||
<span><$text text=<<__prefix__>>/></span>
|
<span><$text text=<<__prefix__>>/></span>
|
||||||
<div>
|
<div>
|
||||||
<$macrocall $name="tree-node" prefix=<<__prefix__>>/>
|
<$macrocall $name="tree-node" prefix=<<__prefix__>> separator=<<__separator__>>/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
\end
|
\end
|
||||||
|
@ -6,3 +6,6 @@ type: text/vnd.tiddlywiki
|
|||||||
|
|
||||||
<$macrocall $name=".example" n="1"
|
<$macrocall $name=".example" n="1"
|
||||||
eg="""<<tree prefix:"$:/">>"""/>
|
eg="""<<tree prefix:"$:/">>"""/>
|
||||||
|
|
||||||
|
<$macrocall $name=".example" n="2"
|
||||||
|
eg="""<<tree prefix:"tree-macro-example-" separator:"-">>"""/>
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
title: tree-macro-example-
|
||||||
|
tag: [[tree Macro (Examples)]]
|
||||||
|
|
||||||
|
house: See [[tree Macro (Examples)]]
|
||||||
|
house-kitchen: See [[tree Macro (Examples)]]
|
||||||
|
house-kitchen-table: See [[tree Macro (Examples)]]
|
||||||
|
house-kitchen-sink: See [[tree Macro (Examples)]]
|
||||||
|
house-kitchen-window: See [[tree Macro (Examples)]]
|
||||||
|
house-attic: See [[tree Macro (Examples)]]
|
||||||
|
house-attic-window: See [[tree Macro (Examples)]]
|
||||||
|
house-attic-roof: See [[tree Macro (Examples)]]
|
||||||
|
house-garden: See [[tree Macro (Examples)]]
|
||||||
|
house-garden-shed: See [[tree Macro (Examples)]]
|
||||||
|
house-garden-lawn: See [[tree Macro (Examples)]]
|
||||||
|
car: See [[tree Macro (Examples)]]
|
||||||
|
car-boot: See [[tree Macro (Examples)]]
|
||||||
|
car-boot-lock: See [[tree Macro (Examples)]]
|
||||||
|
car-boot-handle: See [[tree Macro (Examples)]]
|
||||||
|
car-roof: See [[tree Macro (Examples)]]
|
||||||
|
car-roof-rails: See [[tree Macro (Examples)]]
|
||||||
|
car-roof-aerial: See [[tree Macro (Examples)]]
|
@ -5,11 +5,13 @@ tags: Macros [[Core Macros]]
|
|||||||
title: tree Macro
|
title: tree Macro
|
||||||
type: text/vnd.tiddlywiki
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
The <<.def tree>> [[macro|Macros]] renders an expandable tree view based on tiddler titles.
|
The <<.def tree>> [[macro|Macros]] renders an expandable tree view based on a prefix and separator within tiddler titles.
|
||||||
|
|
||||||
!! Parameters
|
!! Parameters
|
||||||
|
|
||||||
;prefix
|
;prefix
|
||||||
: The prefix from which to generate the tree, e.g. `$:/`
|
: The prefix from which to generate the tree, defaults to `$:/`
|
||||||
|
;separator
|
||||||
|
: The separator between parts of the tiddler titles, defaults to `/`
|
||||||
|
|
||||||
<<.macro-examples "tree">>
|
<<.macro-examples "tree">>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user