Special request

105 views
Skip to first unread message

David Gifford

unread,
Dec 31, 2015, 1:04:06 PM12/31/15
to TiddlyWiki
Greetings from TiddlyWaikiki!

Heading back to Mexico today, but I got an idea and am wondering how to do it.

I would like to have a viewtemplate item that is basically this:  wrap with CSS [[insert contents of sitetitle here|../folder/insert contents of sitetitle here.html]].

So a tiddler whose $:/SiteTitle is hawaii.vacation would automatically render the following: [[hawaii.vacation|../folder/hawaii.vacation.html]]. And I could give it a class. (the relative path to the folder is something I would manually add)

This would go in a template tiddler in a template TW file. This way, when I export any tiddler to html from any file, the tiddler will already have a relative link to the source file. If I upload to my site, I will make sure the folders match with what I have on my hard drive.

Any ideas how I would do this? I tried this

[[<$view tiddler="$:/SiteTitle" field="title"/>|http://recursos.giffmex.org.{{!!SiteTitle}}.html]]

But it doesn't work. Anyway, any help would be appreciated, and I will share here the final results, in case anyone wants to use the idea.

Dave

Dave

David Gifford

unread,
Dec 31, 2015, 2:06:05 PM12/31/15
to TiddlyWiki
This seems closer, but the {{!!$:/SiteTitle}} is the part that doesn't work. Trying to mix too many markups. I am guessing the answer is with dollar signs...

<a href="../folder/{{!!$:/SiteTitle}}.html"><$view tiddler="$:/SiteTitle" field="text"/></a>

Dave

David Gifford

unread,
Dec 31, 2015, 2:13:26 PM12/31/15
to TiddlyWiki
Nor this

\define taglinks(transcludy:"{{$:/SiteTitle}}") <a href="../folder/$transcludy$.html"><$view tiddler="$:/SiteTitle" field="text"/></a>

Jed Carty

unread,
Dec 31, 2015, 4:52:26 PM12/31/15
to TiddlyWiki
I think in this cane you need to use a set widget and macro instead of just a macro. Like this:

\define taglinks()
<a href="./folder/$(transcludy)$.html"><$view tiddler="$:/SiteTitle" filed="text"/></a>
\end

<$set name=transcludy value={{$:/SiteTitle}}>
<<taglinks>>
</$set>

I wrote some stuff about this here along with what does and doesn't work.

Eric Shulman

unread,
Dec 31, 2015, 5:44:01 PM12/31/15
to TiddlyWiki
On Thursday, December 31, 2015 at 11:13:26 AM UTC-8, David Gifford wrote:
\define taglinks(transcludy:"{{$:/SiteTitle}}") <a href="../folder/$transcludy$.html"><$view tiddler="$:/SiteTitle" field="text"/></a>

The problem is much easier to approach if you break it into two parts:

1) First, write a macro that accepts a parameter and uses it to assemble the desired link output

2) Then, invoke the macro using a parameter value retrieved from $:/SiteTitle

For part (1), you've already done most of the work with the macro above.  We can simplify and clean it up a bit:
\define taglinks(here) <a href="""../folder/$here$.html"""><$text text="""$here$"""/></a>

Note the use of """...""" syntax around the attributes in the output.  This is because we cannot ensure that the $here$ value does not contain a double-quote (i.e., if your $:SiteTitle text includes double-quotes).  The tripled double-quotes is a TiddlyWiki enhancement that allows attribute values to contain double-quotes without breaking the rest of the syntax.

For part (2), while it might seem like it should work, the following does *not* work:
<<taglinks here:{{$:/SiteTitle}}>>

This is because the regular <<macroname>> syntax doesn't evaluate it's parameters, and just passes them along as literal text to be used within the macro body. Fortunately, however, if you use the <$macrocall $name="macroname" ... /> widget syntax instead of the <<macroname>> syntax, the widget parameters *are* evaluated.  This allows you to invoke the macro with the desired parameter value, like this:
<$macrocall $name="taglinks" here={{$:/SiteTitle}}/>

Notice how the 'here' parameter does not have any surrounding quotes around the {{...}} syntax.  This is what causes the param value to be retrieved from the indicated tiddler (i.e., $:/SiteTitle).  In contrast, if the parameter was quoted (i.e., here="{{TiddlerName}}"), then the {{...}} syntax would just be passed along as literal text without evaluation.

HTH

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
InsideTiddlyWiki: The Missing Manuals

David Gifford

unread,
Jan 1, 2016, 1:42:37 PM1/1/16
to TiddlyWiki
Thanks to both Jed and Eric, both of your solutions work great!

I am back in Mexico again, with a serious case of jetlag, after a great time in TiddlyWaikiki!


Dave

On Thursday, December 31, 2015 at 8:04:06 AM UTC-10, David Gifford wrote:
Reply all
Reply to author
Forward
0 new messages