On Thursday, December 31, 2015 at 11:13:26 AM UTC-8, David Gifford wrote:
>
> \define taglinks(transcludy:"{{$:/SiteTitle}}") <a
> href="../folder/$transcludy$.html"><$view tiddler="$:/SiteTitle"
> field="text"/></a>
The problem is much easier to approach if you break it into two parts:
1) First, write a macro that accepts a parameter and uses it to assemble
the desired link output
2) Then, invoke the macro using a parameter value retrieved from
$:/SiteTitle
For part (1), you've already done most of the work with the macro above.
We can simplify and clean it up a bit:
\define taglinks(here) <a href="""../folder/$here$.html"""><$text text="""$
here$"""/></a>
Note the use of """...""" syntax around the attributes in the output. This
is because we cannot ensure that the $here$ value does not contain a
double-quote (i.e., if your $:SiteTitle text includes double-quotes). The
tripled double-quotes is a TiddlyWiki enhancement that allows attribute
values to contain double-quotes without breaking the rest of the syntax.
For part (2), while it might seem like it should work, the following does
*not* work:
<<taglinks here:{{$:/SiteTitle}}>>
This is because the regular <<macroname>> syntax doesn't evaluate it's
parameters, and just passes them along as literal text to be used within
the macro body. Fortunately, however, if you use the <$macrocall
$name="macroname" ... /> widget syntax instead of the <<macroname>> syntax,
the widget parameters *are* evaluated. This allows you to invoke the macro
with the desired parameter value, like this:
<$macrocall $name="taglinks" here={{$:/SiteTitle}}/>
Notice how the 'here' parameter does not have any surrounding quotes around
the {{...}} syntax. This is what causes the param value to be retrieved
from the indicated tiddler (i.e., $:/SiteTitle). In contrast, if the
parameter was quoted (i.e., here="{{TiddlerName}}"), then the {{...}}
syntax would just be passed along as literal text without evaluation.
HTH
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/3191e5d1-93d7-4ac8-9407-e86a6c261cb7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.