On Tuesday, June 8, 2021 at 7:03:17 PM UTC-7 [email protected] wrote:
> One more thing if possible , the field part somefield, i need to
> transclude a value there with spaces
> somefield={{!!title}}
> and i cant add brackets , because this turns it into a string
> [[{{!!title}}]]
> Is there any way to insert the value enclosed in brackets ?
>
So... let's say you have a title of "Foo Bar Baz" (i.e., text containing
spaces). Then, when you create a new tiddler using somefield={{!!title}},
the resulting value of somefield will still be "Foo Bar Baz" (i.e., a
single text value containing spaces). For almost all purposes, this will
be sufficient, and subsequent references to {{!!somefield}} will still
result as a single text value containing spaces. Nonetheless, it still
possible to save the field value including added brackets, so that it will
be stored as "[[Foo Bar Baz]]". Here's one method for adding the brackets:
<$button> click me
<$vars lb="[[" rb="]]">
<$action-createtiddler $basetitle="SomethingNew" text="yabba dabba doo!"
tags="foo bar baz" caption="this is a caption" somefield={{{
[{!!title}addprefix<lb>addsuffix<rb>] }}} />
</$vars>
</$button>
Notes:
* The $vars defines two variables that contain the literal "[[" and "]]"
text
* The somefield parameter value is then assembled using "filtered
transclusion" to add the brackets before and after the {!!title} value.
* The $vars is needed because you can't use literal square brackets as text
within the filter syntax, since they would be interpreted as part of the
filter syntax itself (i.e., you can't write ...addprefix[[[]... or
...addsuffix[]]]...)
Another way to achieve this is to use macros instead of $vars to define the
lb and rb variables, like this:
\define lb() [[
\define rb() ]]
<$button> click me
<$action-createtiddler $basetitle="SomethingNew" text="yabba dabba doo!"
tags="foo bar baz" caption="this is a caption" somefield={{{
[{!!title}addprefix<lb>addsuffix<rb>] }}} />
</$button>
enjoy,
-e
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/4d444bdb-faf5-4681-98ae-2d83238d469cn%40googlegroups.com.