[TW5] concatenating title and textreference into a filter operand

126 views
Skip to first unread message

Tobias Beer

unread,
Nov 22, 2014, 1:58:48 PM11/22/14
to tiddl...@googlegroups.com
Read below or first take a look at...


Starting from tiddlers like...
  • BookB
  • BookB / ChapterC
  • BookB / ChapterC / PageP
I am trying to display a list at the bottom of BookB
showing the "subtiddlers" based on BookB functioning as a prefix.

While that's easy to achieve using [prefix<<currentTiddler>>],
I am now trying to remove "BookB / " from BookB / ChapterC so as to
construct a link that reads [[ChapterC|BookB / ChapterC]]

To do that, I introduced $:/config/ChapterDelimiter and
specifyied " / " as the delimiter to then
concatenate the current tiddler as my prefix with it using $set, all in all...

<$list filter="[prefix<currentTiddler>sort[title]]-[<currentTiddler>]" variable="sub">
<$set variable="remove" value="<
<currentTiddler>>{{$:/config/ChapterDelimiter}}">
<$list filter="[
<sub>removeprefix<remove>]" variable="truncated">
<$link to=<<sub>>><<truncated>></$link><br>
</$set>
</$list>
</$list>

The problem is, I never reach the inner list, i.e. the remove variable just won't yield the desired filter.

The problem must lie in the variable as it all works if I do it with simple strings...


I also noticed that when I save my delimiter $:/config/ChapterDelimiter as " / " and then transclude it via...

{{$:/config/ChapterDelimiter}}


...then the leading <blank> is trimmed! This definitely appears to be a bug.

Best wishes, Tobias.

Stephan Hradek

unread,
Nov 22, 2014, 2:14:23 PM11/22/14
to tiddl...@googlegroups.com
Try this:

\define remover() $(currentTiddler)$$(delim)$

<$set name="delim" value=
{{$:/config/ChapterDelimiter}}>

<$list filter="[prefix
<currentTiddler>sort[title]]-[<currentTiddler>]" variable="sub">
<$list filter="[<sub>removeprefix<remover>]" variable="truncated">
<$link to=<<sub>>><<truncated>></$link><br>
</$list>
</$list>

</$set>

Tobias Beer

unread,
Nov 23, 2014, 1:20:39 PM11/23/14
to tiddl...@googlegroups.com
Thanks Stephan, that worked perfectly :)

Will be thinking of using helper macros from now on for preprocessing vars.

Best wishes, Tobias.
Reply all
Reply to author
Forward
0 new messages