appending to external links

43 views
Skip to first unread message

James Anderson

unread,
Jun 16, 2021, 5:50:58 AM6/16/21
to TiddlyWiki
Hello, 

wondering how i can achieve the following (admittedly contrived) example:

lets say I have a tiddler called Search which contains:

www.google

then in another tiddler i want to use this to create external links to different sites e.g. 

{{Search}}.com -> www.google.com
{{Search}}.co.uk -> www.google.co.uk
{{Search}}.fr -> www.google.fr

the following doesn't work:
<a href={{Search}}.com> link 1</a>

what is the right syntax to achieve this?

Thanks,
James

Eric Shulman

unread,
Jun 16, 2021, 6:19:25 AM6/16/21
to TiddlyWiki
On Wednesday, June 16, 2021 at 2:50:58 AM UTC-7 james.w....@gmail.com wrote:
lets say I have a tiddler called Search which contains:
www.google
then in another tiddler i want to use this to create external links to different sites e.g. 
{{Search}}.com -> www.google.com
{{Search}}.co.uk -> www.google.co.uk
{{Search}}.fr -> www.google.fr

the following doesn't work:
<a href={{Search}}.com> link 1</a>
what is the right syntax to achieve this?
 
To construct a parameter value (i.e., the value following the "href=" syntax), you need to use a "filtered transclusion", like this:

<a href={{{ [{Search}addsuffix[.com]]   }}}> link 1</a>
<a href={{{ [{Search}addsuffix[.co.uk]] }}}> link 2</a>
<a href={{{ [{Search}addsuffix[.fr]]    }}}> link 3</a>

Notes:
1) The filtered transclusion syntax is contained within tripled curly braces: {{{ filter }}}
2) The filter syntax itself is contained inside a matched pair of single square brackets: [...]
3) To reference the text content of a tiddler within a filter, use single curly braces: {TiddlerName}
4) To append the desired literal text (i.e., ".com", ".co.uk", etc.) use the addsuffix[...] operator

enjoy,
-e

James Anderson

unread,
Jun 16, 2021, 6:56:03 AM6/16/21
to TiddlyWiki
perfect, thanks Eric!
Reply all
Reply to author
Forward
0 new messages