In the attached TiddlyWiki I describe a strange issue with ‘list-links’. I don’t know if this is an error or I just missed something.
(Attachment strange_list_error.html is missing)
In the attached TiddlyWiki I describe a strange issue with ‘list-links’. I don’t know if this is an error or I just missed something.
(Attachment strange_list_error.html is missing)
Here’s your code that doesn’t work:
\define listtitle() ''Books by $(currentTiddler)$''
\define filter() "[tag[$(currentTiddler)$]tag[Book]]"
<$list filter=<<filter>> variable="_"> <<listtitle> </$list>
<<list-links filter:"[tag[$(currentTiddler)$]tag[Book]]">>
Here’s what’s wrong:
There is a missing >
at the end of <<listtitle>
. As a result, the macro call isn’t closed until the final >>
at the end of the code. All the content between the error and the ending >>
are treated as parameters to the macro.
The $(variablename)$
syntax is only parsed when it occurs within a macro. Thus, "[tag[$(currentTiddler)$]tag[Book]"
is actually looking for a literal tag value of $(currentTiddler)$
.
You don’t need the double-quotes around the content of \define filter() "..."
.
If there are multiple Book tiddlers for the current Author, your <$list>
widget (with the correction for the missing >
) would display the <<listtitle>>
text multiple times, once for each matching Book tiddler.
You don’t actually need to use $(currentTiddler)$
anywhere in the above code… <<currentTiddler>>
(or <currentTiddler>
within a filter) is sufficient. In fact, you don’t need to use any macros at all.
Here’s some corrected/simplified code:
<$list filter="[tag<currentTiddler>tag[Book]limit[1]]" variable="_">''Books by <<currentTiddler>>''</$list>
<<list-links filter:"[tag<currentTiddler>tag[Book]]">>
Notes:
limit[1]
so that the heading text is only displayed once, regardless of how many matching Book tiddlers are found.enjoy,
-e
@Eric Shulman
Thank you for enlightening me!
at 1) A case of blindness: I missed the missing >
at the end of `<, because the list title was always displayed.
at 2) I defined the macros, because I hope that some day I can use transclusions with parameters and pass in ‘Book’, ‘Article’, ‘Video’, etc. But even then, as your code shows, I probably wouldn’t need them.
at 3) A misunderstanding: These are not double quotes, but two double single quotes to make the list title bold.
at 4) A case of laziness: I only tested for zero and one cases, not for more than one.
at 5) A case of ignorance: I’m not yet familiar with the finer details of the use of angle brackets within text and filters. Thanks for the clarification.
Your corrected /simpilified code works as desired!
Thanks again,
-Reinhard