Thanks again, Eric. I'm using the first method as I find it little easier 
to follow (especially for later when I may have forgotten what's going on). 
I'm considering how to make it more general and not just hardwired to 
https://orcid.org 
and assume I can use both $(...)$ and $...$ in the same macro... I wonder 
whether this is good practice or not... so maybe it would be better to pass 
all variables into a macro using the second method with param1=<<value1>> 
param2=<<value2>> etc. in the $macrocall.

Take care,

Anthony

On Thursday, 12 November 2020 at 16:00:57 UTC Eric Shulman wrote:

> On Thursday, November 12, 2020 at 6:06:14 AM UTC-8, Anthony wrote:
>>
>> Thanks Eric, I guess the '<currentTiddler>' just creates a filtered list 
>> from the current tiddler and whether text is displayed depends on this 
>> being null or not.
>>
>
> "[<currentTiddler>has[death-date]]" means "if the current tiddler has a 
> non-blank death-date field"
>
> Without using <currentTiddler> at the beginning of the filter, then filter 
> would be applied to ALL tiddlers by default,
> and "has[death-date]" would produce output for every tiddler with a 
> non-blank death-date field, not just the current one.
>
> Now, using the same methodology, I'm trying to construct an external link 
>> and tried:
>>
>> <$list filter="[<currentTiddler>has[orcid]]">
>>    ''ORCID'': [[{{!!orcid}}|https://orcid.org/{{!!orcid}}]]
>> </$list>
>>
>
> The problem here is that TiddlyWiki syntax doesn't "nest".  That is, you 
> can't use one kind of syntax
> such as transclusion -- {{!!orcid}} -- within another, such as a link -- 
> [[text|url]].
>
> You can, however, *construct* the link syntax by using a macro, like this:
> \define mylink() [[$(this_orcid)$|https://orcid.org/$(this_orcid)$]]
>
> <$list filter="[<currentTiddler>get[orcid]]" variable="this_orcid">
>    ''ORCID'': <<mylink>>
> </$list>
>
> Note that the filter uses "get[orcid]" rather than "has[orcid]". This not 
> only tests to see if the "orcid" field is non-blank, but also fetches it's 
> value, which is set into the "this_orcid" variable. Then, the 
> $(this_orcid)$ syntax within the macro does a string substitution, based on 
> the current value of the "this_orcid" variable.
>
> Note also that the $(...)$ syntax can only be used within a macro.  Keep 
> in mind that macros only do two things:
>
>    1. replace instances of $(...)$ with values from variables, where the 
>    variables are defined *outside* of the macro
>    2. replace instances of $...$ with values from parameters, where the 
>    parameters are passed into the macro
>
> All other processing of the macro output is performed by the calling 
> context.  In the above example, this means the resulting link syntax -- 
> [[foo|https:/orcid.org/foo]] -- is parsed and wikified after being 
> "returned" from the macro.
>
> Another point about macro syntax:  if you want to use the "parameter" 
> method to pass the "this_orcid" value into the macro, you would write 
> something like this:
> \define mylink(id) [[$id$|https://orcid.org/$id$]]
>
> <$list filter="[<currentTiddler>get[orcid]]" variable="this_orcid">
>    ''ORCID'': <$macrocall $name="mylink" id=<<this_orcid>> />
> </$list>
>
> Note the use of the <$macrocall> widget to invoke the "mylink" macro with 
> the "id" parameter set to the current value of the "this_orcid" variable. 
> This is needed because you can't nest the variable reference -- 
> <<this_orcid>> within the shorthand <<mylink>> syntax; i.e., you CANNOT 
> write <<mylink <<this_orcide>>>> because the closing ">>" of the variable 
> reference would be seen as ending the enclosing macro, with the second ">>" 
> being left over to "fall out" as displayed text.
>
> TiddlyWiki syntax is consistent, but somewhat less flexible than other 
> languages.  While this may be a little confusing at first, once you get 
> used to it's peculiarities, it becomes easier.
>  
>
>> Apologies, I can't figure out how to format the code in monospace in a 
>> grey-background box.
>>
>
> That is a feature of the old GoogleGroups editing interface that they have 
> inexplicably left out of the new interface. To view this group using the 
> old interface (which I prefer), you can use a URL like this:
>
> https://groups.google.com/forum/?oldui=1#!forum/tiddlywiki
>
> 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/a6b3ca06-b4d3-490c-b0c0-78818521f02fn%40googlegroups.com.

Reply via email to