On Friday, December 30, 2016 at 11:35:20 AM UTC-8, stevesuny wrote:
>
> I've got this macro:
> \define see(show,go)
> <$link to=$go$ tooltip="hello">$show$</$link>
> \end
> I'd like to set the tooltip to a field of the $go$ tiddler (text, caption,
> tooltip, etc.) when the link is created with the <<see>> macro.
>
You are passing in "go" as a macro param. As you clearly already know,
this allows you to use $go$ to perform a *lexical substitution* so that the
value of the "go" param in is inserted into the surrounding syntax. The
macro then "returns" the content, including the substitutions, for further
processing by the TiddlyWiki parser.
To retrieve the value of the tooltip from a tiddler field (instead of the
literal "hello" placeholder in your example), the syntax is:
tooltip={{tiddlername!!fieldname}}
and, given that you have $go$ defined, you can write:
tooltip={{$go$!!tooltip}}
where 'tooltip' is the desired field name.
Note: there's a small error in your macro code. In the $link widget, you
wrote:
to=$go$
However, if $go$ is a tiddler title that contains spaces, this will break,
as any text following the space will be treated as another widget parameter
rather than being a part of the value assigned to the "to" parameter. To
make sure spaces in titles are properly contained, you should enclose the
parameter value in quotes:
to="$go$"
In addition, if the value of $go$ includes one or more double-quote
characters, you would need to use the tripled-quotes, like this:
to="""$go$"""
which ensures that any quote character(s) within the title will not be seen
as a delimiter for the value, but will be treated as regular text content
instead.
Putting it all together:
\define see(show,go)
<$link to="""$go$""" tooltip={{$go$!!tooltip}}">$show$</$link>
\end
enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
InsideTiddlyWiki: The Missing Manuals
--
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/8c551602-d402-474a-8859-c934b0d75ba8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.