how to add tiddler size to ViewTemplate?

23 views
Skip to first unread message

RA

unread,
Nov 25, 2009, 8:31:39 PM11/25/09
to TiddlyWiki
I'd like to show tiddler size in it's subtitle. Possible?

--R

Michael.Tarnowski

unread,
Nov 29, 2009, 10:51:07 AM11/29/09
to TiddlyWiki
Hi,
you get the tiddler size by the function call: var x =
tiddler.tiddlerSize().
Using InlineJavaScript place <script> return tiddler.tiddlerSize() </
script> in your viewtemplate .

HTH
Cheers Michael

RA

unread,
Nov 29, 2009, 11:37:46 AM11/29/09
to TiddlyWiki
Michael, you must have some Javascript library that allows you to use
the code you provided.

I don't have tiddlerSize in my wiki. And "tiddler" is actually
accessed as story.findContainingTiddler(place).

There is a complete example in InlineJavascriptPluginInfo, but it
doesn't work from ViewTemplate.

<script show>
if (!window.story) window.story=window;
var title=story.findContainingTiddler(place).getAttribute("tiddler");
var size=store.getTiddlerText(title).length;
return title+" is using "+size+" bytes";
</script>

So how do I use <script> in ViewTemplate?

Eric Shulman

unread,
Nov 30, 2009, 11:47:29 PM11/30/09
to TiddlyWiki
> So how do I use <script> in ViewTemplate?

Put it in a separate tiddler (e.g., [[ShowTiddlerSize]]), and then
transclude it into the template, using:

<span macro='tiddler ShowTiddlerSize'></span>

enjoy,
-e
Reply all
Reply to author
Forward
0 new messages