<<tiddler>> macro - transclude without <span> wrapper

35 views
Skip to first unread message

Michael Mahemoff

unread,
Oct 5, 2009, 4:46:55 AM10/5/09
to tiddly...@googlegroups.com
Is there an option for <<tiddler>>, or some other macro, to just show
the tiddler text, without wrapping it in a <span> tag?

(Use case: I'm making a plugin that reads URLs from slice values.
Normally, it would be a standard HTTP URL, but if it's a long data:
URI, the user might prefer to dump the full data: URI in a separate
tiddler. But if there's no standard way to do it, I'll probably
provide a helper macro for the job, which would be trivial to
implement, but non-standard.)

FND

unread,
Oct 5, 2009, 7:04:53 AM10/5/09
to tiddly...@googlegroups.com
> Is there an option for <<tiddler>>, or some other macro, to just show
> the tiddler text, without wrapping it in a <span> tag?

The tiddler macro doesn't support this at the moment. A wrapper is
required is to ensure the content is updated when the transcluded
tiddler is modified (see config.macros.tiddler.handler for details).

> Use case: I'm making a plugin that reads URLs from slice values.
> Normally, it would be a standard HTTP URL, but if it's a long data:
> URI, the user might prefer to dump the full data: URI in a separate
> tiddler.

It sounds like you are retrieving data from the DOM instead of from the
tiddler object. Is there a particular reason for that?
If you used the built-in TiddlyWiki.prototype.getTiddlerText method,
you'd get support for ::slices and ##sections notation for free.


-- F.

Eric Shulman

unread,
Oct 5, 2009, 7:06:30 AM10/5/09
to TiddlyWikiDev
Normally, you could simply write:
<<tiddler TiddlerName::slicename>>
to fetch and render the slice value. However, as you've noted,
the <<tiddler>> macro creates a "transclusion wrapper" -- a span in
which to render the transcluded content.

This is in done in order to apply special attributes
(refresh="content", tiddler="TiddlerName") that allows the core to
locate the transclusion wrappers and automatically *refresh them*
whenever their underlying tiddlers have changed, so that the rendered
content can stay in sync with the stored data.

Although it's unclear to me why you find this use of a containing span
is undesirable, here's a way to bypass the normal action of the
<<tiddler>> macro using an 'eval param' to directly wikify() and
append output to the current 'place':

<<tiddler {{wikify(store.getTiddlerText
('AttachFileSample##data'),place);'';}}>>

Note that in the above example, the tiddler 'returns' a blank text
string as the result of the eval param. Inasmuch as a blank string
can never be a valid TiddlerName, this prevents the macro from
retrieving and rendering specified tiddler content into the
transclusion wrapper.

However... the macro still *does* create an *empty* wrapper element as
usual, immediately following the wikified content that was directly
rendered by the eval param. If this empty wrapper span is not an
issue, then I think that the above technique should meet your needs.

However, if the empty span *is* a problem for you, then you could use
http://www.TiddlyTools.com/#InlineJavascriptPlugin
like this:
<script>
return store.getTiddlerText('TiddlerTitle::slicename');
</script>
By design, any text returned from an inline script is wikified
and rendered directly onto the end of the current 'place', without
creating a transclusion wrapper element like the <<tiddler>> macro
does.

enjoy,
-e

Michael Mahemoff

unread,
Oct 5, 2009, 2:23:10 PM10/5/09
to tiddly...@googlegroups.com
Thanks for your explanations. I didn't explain my problem well enough,
though you've answered my question well enough for me to know that
what I'm seeking isn't possible.

For the record, I'll explain it again in more detail. I've developed
an <<infoBox>> macro to show mediawiki-like info boxes. The tiddlywiki
author writes:

<<infoBox type:warning>>

and the macro then looks up a tiddler called "warningInfoBox", which
contains some slices:

|message|Please follow these instructions carefully.|
|icon|http://example.com/warning.png|

The above model is simple, but in some cases, the user might want:

|icon|data:blahblahblahgarbagegarbage....|

which works just as well (in modern browsers), but the warningInfoBox
tiddler containing these slices becomes unwieldy. An alternative would
ideally be:

|icon|<<tiddler stopIcon>>|

with "stopIcon" tiddler populated with the whole data URI string,
nicely isolating it away, and in a way that's very intuitive for any
user familiar with <<tiddler>>. To allow for this indirection, my code
would simply run wikifyStatic() on the slice value.

However, the indirection fails because of the <span> wrapper. It's not
a big deal. I suppose one solution would be a boolean "raw" parameter
for the tiddler macro, but then again asking the user to use
"raw:true" is defeating the purpose of simplicity anyway.

Reply all
Reply to author
Forward
0 new messages