Using a field value in a macro for a link

I feel like I’m missing something which in my mind should be easy but I’m coming up on a blank. I would like to write a custom macro which creates an external link but only if the current tiddler has a certain field. In this case, the title of the field name is osm. The value of osm is a url, pointing to it’s location on OpenStreetMap. I would like to be able to write <<osmlink>>. Or do this through a transclusion. Here is an example tiddler below.

The Central Saloon.json (478 Bytes)

I’m not sure what creates an external link” means, but maybe it’s as simple as:

\define osmlink() {{!!osm}}

1 Like

Ah actually I think I figured it out… I had forgotten to close the view widget. I ended up making a simple macro as follows:

\define osmlink()
<a href={{!!osm}} class="tc-tiddlylink-external">~OpenStreetMap Location</a>
\end

There is another topic on this subject, but it’s a bit complex to follow.

1 Like