Questions about tv-get-export-link variable

I’m generating a static version of my wiki, and I’d like to adjust the links between tiddlers to match the directory structure that I want to use.

To do this, I adjusted the template used to render each tiddlers, adding a definition to generate the proper href for each link, as follows:

\procedure tv-get-export-link(to) <$text text={{{[<to>get[created]format:date[../YYYY]addsuffix[/]] [<to>encodeuricomponent[]encodeuricomponent[]addsuffix[.html]] :reduce[addprefix<accumulator>]}}}/>

that code creates texts like “…/year-of-tiddler-creation/tiddler-title.html”

however, I’m not getting the expected result; the target for each link, in the static HTML I receive, is just the code for the procedure; in other words, all links point to <$text text={{{[<to>get[created]format:date[../YYYY]addsuffix[/]] [<to>encodeuricomponent[]encodeuricomponent[]addsuffix[.html]] :reduce[addprefix<accumulator>]}}}

when I define tv-get-export-link as a macro, (and use [$to$] instead of <to> in my filtered transclusion), $to$ is interpolated as expected, but the link href value is now the body of the macro, with $to$ interpolated, but the rest of the macro code is not executed.

… is this a bug in tv-get-export-link/the <$link> widget?

EDIT: I forgot to mention: when I test the procedure/macro definitions in a live TW, I get the expected result (e.g., …/2025/index.html, for a tiddler called index.)

Try definining it as a function, like this:

\function tv-get-export-link(to)
[<to>get[created]format:date[../YYYY]addsuffix[/]]
[<to>encodeuricomponent[]encodeuricomponent[]addsuffix[.html]]
+[join[]]
\end

Unlike macros (\define) or procedures (\procedure), which simply return their literal content for further processing (which MIGHT be wikified if rendered in a wikitext context), a function contains ONLY filter syntax which is evaluated before its value is returned, which can then be used as parameter values in other widgets. Thus, the calling code can use the above tv-get-export-link function like this:

<$let foo=<<tv-get-export-link test>>>
or
<$codeblock code=<<tv-get-export-link test>>/>

-e

3 Likes

Thanks for this clarification! I am ashamed to be still very dizzy about the differences between function procedure and define