Multi-reference attribute in $let

I’m trying to create something like <$let var=foo.{{!!bar}}.car>... so that if bar’s value is xxx, then var will be foo.xxx.car. I’m not able to do it. The attribute value is the literal above. If I put quotes it still is the literal. So, what is the way to achieve this?

You need to use the “filtered transclusion” syntax to construct the desired value, like this:

<$let var={{{ [[foo]] [{!!bar}] [[car]] +[join[.]] }}}>

enjoy
-e

1 Like

This is kind of verbose… is there a slimmer way?
Also, I just used dots for this example, in my real use case I the text between text references is different.

You could also do this using the $wikify widget, like this:

<$wikify name="var" text="foo.{{!!bar}}.car">

-e

It’s best practice. the wikify widget should be the last resort if there is no other way.

1 Like

You can changed the parameter of join[] to any text you like, or use it like this

<$let var={{{ [[foo.]] [{!!bar}] [[.car]] +[join[]] }}}>

where you can change the periods to anything you like, independent of each other.

It is indeed verbose and hard to follow. There is a proposal for a shortcut syntax for textual substitution: Add support for string literal attributes with textual substitution · Issue #6663 · Jermolene/TiddlyWiki5 · GitHub

With that proposal, your example would be:

 <$let var=`foo.${ [{!!bar}] }$.car`>
5 Likes