templates / transclusion (parametric)

91 views
Skip to first unread message

FND

unread,
Mar 21, 2007, 3:55:52 AM3/21/07
to Tiddl...@googlegroups.com
Hi all,

Here's a random thought that just popped into my head:
It'd be nice if you could use templates similar to what's possible with
the MediaWiki engine.
I know that simple transclusion is possible using the <<tiddler>> macro,
but there's no way to use parameters with that (AFAIK).

For example, say I keep track of quotes a lot, and they'd always be in
the following format:
<<<
[quote]
<<<
{{source{[author]}}}
So I'd create a tiddler "quoteTemplate" with that content, and could use
<<template quoteTemplate "This is a quote." "me">>
to ensure that quotes are consistently formatted.

This would, of course, be less crucial for TiddlyWiki than for "proper"
wiki engines (like MediaWiki), but it might still be a nice thing to have...


-- F.

Jeremy Ruston

unread,
Mar 21, 2007, 5:35:53 AM3/21/07
to Tiddl...@googlegroups.com
Gosh, I've just realised that the <<tiddler>> macro is currently
undocumented, whoops.

Anyway, you can in fact use parameters with the <<tiddler>> macro. For
instance, if you have a tiddler called HelloThere with the text "Hello
\0 and \1", in another tiddler you can use the macro call <<tiddler
HelloThere with:"Jeremy" "Danny">> to display the text "Hello Jeremy
and Danny".

Cheers

Jeremy


--
Jeremy Ruston
mailto:jer...@osmosoft.com
http://www.tiddlywiki.com

FND

unread,
Mar 21, 2007, 5:48:18 AM3/21/07
to Tiddl...@googlegroups.com
Thanks for the quick response, Jeremy!

> Gosh, I've just realised that the <<tiddler>> macro is currently
> undocumented, whoops.

I'd actually looked up the tiddler macro before posting this, but
couldn't find any documentation - so I just assumed it didn't accept any
parameters other than the tiddler name...

> Anyway, you can in fact use parameters with the <<tiddler>> macro.

That's awesome!!
However ...

> For instance, if you have a tiddler called HelloThere with the text "Hello
> \0 and \1", in another tiddler you can use the macro call <<tiddler
> HelloThere with:"Jeremy" "Danny">> to display the text "Hello Jeremy
> and Danny".

... this doesn't seem to work for me.
Starting with an empty TW, I did exactly as you described. But all I get
from the macro call is "Hello \0 and \1" - so the parameters are not
expanded.
I've also tried a couple of variations (omitting "with:", using just a
single parameter etc.), but I can't get it working!?


-- F.

Jeremy Ruston

unread,
Mar 21, 2007, 5:56:55 AM3/21/07
to Tiddl...@googlegroups.com
Oops, that's because I can't type. I should have said:

For instance, if you have a tiddler called HelloThere with the text "Hello

$0 and $1", in another tiddler you can use the macro call <<tiddler


HelloThere with:"Jeremy" "Danny">> to display the text "Hello Jeremy
and Danny".

Cheers

Jeremy

On 3/21/07, FND <Ace_...@gmx.net> wrote:
>

FND

unread,
Mar 21, 2007, 6:14:26 AM3/21/07
to Tiddl...@googlegroups.com
> Oops, that's because I can't type. I should have said:

D'oh - I could've thought about the proper variable notation myself!
However, there's another mistake; seems like the array(?) is one-based,
not zero-based. So it should be something like this:
QuoteTemplate:
<<<
$1
<<<
{{{$2}}}
usage:
<<tiddler QuoteTemplate with:"The quote." "The source.">>

Anyways, thank you so much!


-- F.

FND

unread,
May 25, 2007, 3:00:37 AM5/25/07
to Tiddl...@googlegroups.com
> Anyway, you can in fact use parameters with the <<tiddler>> macro.

Just a quick note, for whoever is interested:
If you want to use a template tiddler's References list to check which
tiddlers are using said template, you should enclose the transcluded
tiddler in [[brackets]], like this:
<<tiddler [[templateTiddler]] with: ... >>
(probably not required if "templateTiddler" was a CamelCase title)


-- F.

FND

unread,
May 25, 2007, 3:29:21 AM5/25/07
to Tiddl...@googlegroups.com
quick update:

> probably not required if "templateTiddler" was a CamelCase title

That's correct - which is why I've just changed my templates' names from
"tName" to "TemplateName".
That's a lot easier now, and a lot less error-prone too (I'd never
remember to manually put the brackets... ).


-- F.

eirich

unread,
Mar 26, 2012, 7:34:40 PM3/26/12
to tiddl...@googlegroups.com, Tiddl...@googlegroups.com, jeremy...@gmail.com
Is there any way to have more than $1-9?  $0 doesn't seem to work on my installation and neither does anything above $9.
Reply all
Reply to author
Forward
0 new messages