On Sunday, June 7, 2020 at 3:20:27 AM UTC-7, Jake wrote: > > The question is can I use a transclusion in hyperlinks? > Can I make a tiddler like [[MyFolder Path]] and then use > [[myfile|file:///{{MyFolder Path}}\MySubfolder\myfile.txt]]? And if I > rename/move my folder - I just adjust the single tiddler [[MyFolder Path]] > and that's it, no need to rename ALL the links. > ...Maybe some macro or something?... >
Yes... a macro (actually 2 macros) First, enter this into a tiddler (e.g., MyLink) tagged with $:/tags/Macro: \define link(text,file) <$vars folder={{MyFolderPath}}><<link2file "$text$" "$file$">></$vars> \define link2file(text,file) [ext[$text$|file:///$(folder)$/$file$]] Next, create a tiddler named "MyFolderPath", containing something like: C:/MyFolder02 Then, to use it, write: <<link "text to show" "MySubfolder/myfile.txt">> What it does: The <<link>> macro gets the contents of MyFolderPath and puts it in a variable and then calls on <<link2file>>. The <<link2file>> macro substitutes the macro parameters, $text$ and $file$ along with the variable $(folder)$ to construct and return an external link for rendering. Note: * even though Windows uses backslash in path names, we can use *forward slash* within the browser. This makes it cross-platform compatible, since other platforms (e.g., Linux) use forward slash exclusively. 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 tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/37ae1e2f-3ba3-4ec9-b86c-94a78cf1f4a3o%40googlegroups.com.