Code in code

131 views
Skip to first unread message

vinvi...@gmail.com

unread,
Sep 4, 2020, 3:58:55 PM9/4/20
to TiddlyWiki
Hello,

I have a piece of code that uses details macro from the Shiraz plugin.
This is the piece of code:

<< details sum: "NameOfCurrentTiddlerHere" "BodyTextHere" class: "alert-primary" >>

It all works fine, but how do I make the current tiddler title appear automatically with: "NameOfCurrentTiddlerHere" as a link?



In the place "Body text here" I want a list of links. For this I have the following code:

<< list-links filter: "[tag <currentTiddler>] + [tag [NameOfTheTag]]" >>

The code is correct but if I paste it between the other code it is not working. How do I do this?

Thank you,

Eric Shulman

unread,
Sep 4, 2020, 4:26:59 PM9/4/20
to TiddlyWiki
As you have discovered, you can't use macro syntax as parameter values *inside another macro*.

To get around this, you should use the <$macrocall> widget with *named* parameters, like this:
<$macrocall $name="details" sum=<<currentTiddler>> src="""<<list-links filter:"[tag<currentTiddler>] + [tag[NameOfTheTag]]">>""" class="alert-primary"/>
Note that the src parameter value is surrounded by tripled quotes.  This is needed to allow you to use the regular quote character within the parameter value.

Alternatively, if you define a macro to specify the parameter value, you could write it like this:
\define detailsSrc() <<list-links filter: "[tag<currentTiddler>] + [tag[NameOfTheTag]]">>

<$macrocall $name="details" sum=<<currentTiddler>> src=<<detailsSrc>> class="alert-primary" />

enjoy,
-e

vinvi...@gmail.com

unread,
Sep 5, 2020, 9:36:08 AM9/5/20
to TiddlyWiki
Thank you for your response Eric Shulman.

But unfortunately it doesn't work. Nothing happens. The bar appears but there is nothing in it. There must be a flaw in it, but I can't find it. I wonder where in the code I can put my text. I have tried in different ways to also be able to put my text somewhere but it does not work.

Also the page title appears, but not as a link.
Something like this should happen:
<$ link to = <<currentTiddler> >> <$ view field = "title" /> </ $ link>

Can you find out why it doesn't work?

Op vrijdag 4 september 2020 om 22:26:59 UTC+2 schreef Eric Shulman:

Eric Shulman

unread,
Sep 5, 2020, 10:42:26 AM9/5/20
to TiddlyWiki
On Saturday, September 5, 2020 at 6:36:08 AM UTC-7, vinvi...@gmail.com wrote:
Also the page title appears, but not as a link.
Something like this should happen:
<$ link to = <<currentTiddler> >> <$ view field = "title" /> </ $ link>

Are you including all those spaces in your syntax?  If so, that is at least part of the problem.

TiddlyWiki syntax is very particular.  Unlike other programming languages, whitespace is important.  There cannot be spaces in between the "$" and the widget name, nor between a parameter name and the "=". Similarly, doubled angle brackets surrounding a variable name must be kept together and there cannot be spaces in the closing "/$widgetname".

Extra spaces ARE permitted surrounding "param=value" and in-between widgets (though this can result in spaces being displayed in the output).

Thus, the above line of code should properly be written like this:
<$link to=<<currentTiddler>>><$view field="title"/></$link>

Similarly, in the <<list-links>> filter parameter, spaces matter as well.  Your filter syntax currently reads as:
"[tag<currentTiddler>] + [tag[NameOfTheTag]]"

However, there should not be a space between the "+" and the filter expression that follows.  Thus:
"[tag<currentTiddler>] +[tag[NameOfTheTag]]"

In fact, while the +[...] syntax can be used to combine two filter expressions (i.e., as an "AND"), you can also write this as:
"[tag<currentTiddler>tag[NameOfTheTag]]"

Which also means: has a tag equal to the <currentTiddler> name AND a tag equal to "NameOfTheTag"

Please try fixing your syntax by removing all the errant spaces, and then let me know what happens...

-e

Eric Shulman

unread,
Sep 5, 2020, 11:33:05 AM9/5/20
to TiddlyWiki
On Saturday, September 5, 2020 at 7:42:26 AM UTC-7, Eric Shulman wrote:
<$link to=<<currentTiddler>>><$view field="title"/></$link>

Addendum:

Note that the above syntax can be reduced to just
<$link/>
because the to=... parameter defaults to the <<currentTiddler>> value, and the display content defaults to the title being linked

-e

vinvi...@gmail.com

unread,
Sep 5, 2020, 3:58:44 PM9/5/20
to TiddlyWiki
Thanks,

I see what you mean .. Somehow that happened with cut and paste. I don't have it in my wiki that way.
Here's what I've got so far: (The page title will now appear as a link, the rest still doesn't work.) 

<$macrocall $name="details" sum="<$link/>" src="""<<list-links filter:""[tag<currentTiddler>tag[NAME-OF-TAG]]">>""" class="alert-primary"/>



Op zaterdag 5 september 2020 om 17:33:05 UTC+2 schreef Eric Shulman:

Eric Shulman

unread,
Sep 5, 2020, 4:40:18 PM9/5/20
to TiddlyWiki
On Saturday, September 5, 2020 at 12:58:44 PM UTC-7, vinvi...@gmail.com wrote:
I see what you mean .. Somehow that happened with cut and paste. I don't have it in my wiki that way.
Here's what I've got so far: (The page title will now appear as a link, the rest still doesn't work.) 

<$macrocall $name="details" sum="<$link/>" src="""<<list-links filter:""[tag<currentTiddler>tag[NAME-OF-TAG]]">>""" class="alert-primary"/>

I see TWO double-quotes immediately after filter: ... there should be only one.

-e
Message has been deleted

vinvi...@gmail.com

unread,
Sep 6, 2020, 10:11:59 AM9/6/20
to TiddlyWiki
Eric, 

I have solved the problem. Have upgraded to a new version of the plugin. It's working.

Many thanks for your help


Op zaterdag 5 september 2020 om 22:40:18 UTC+2 schreef Eric Shulman:
Reply all
Reply to author
Forward
0 new messages