calling tiddler's name within a script?

10 views
Skip to first unread message

bopaige

unread,
Jul 20, 2009, 12:53:23 PM7/20/09
to TiddlyWiki
Is it possible, within a script, to know the name of the tiddler that
is calling it? I want to develop a simple script that does something
based on the name of the tiddler that is calling it.

Mark S.

unread,
Jul 20, 2009, 11:14:09 PM7/20/09
to TiddlyWiki
<script>
var here = story.findContainingTiddler(place) ;
var title = here.getAttribute('tiddler') ;
wikify(title,place) ;
</script>

(Code somewhat lifted from that of Eric Shulman)

HTH
Mark

Bob Paige

unread,
Jul 21, 2009, 8:17:36 AM7/21/09
to Tiddl...@googlegroups.com
Mark,

Thanks for the response.

I tried this within a macro and 'here' is null.

-- 
Bobman

Bob Paige

unread,
Jul 21, 2009, 8:27:56 AM7/21/09
to Tiddl...@googlegroups.com
There may be a simpler way to accomplish what I want.

What I am trying to do is write a macro that returns all tiddlers tagged with this one and some additional tags (parameters to the macro).

Does this help the solution?

-- 
Bobman

FND

unread,
Jul 21, 2009, 2:16:49 PM7/21/09
to Tiddl...@googlegroups.com
> Is it possible, within a script, to know the name of the tiddler that
> is calling it?

Macros have access to the tiddler variable:
http://tiddlywiki.org/wiki/Dev:Macros

If you're talking about using Eric's InlineJavaScriptPlugin, I think
that passes similar information - check the documentation perhaps?


-- F.

Bob Paige

unread,
Jul 21, 2009, 2:30:32 PM7/21/09
to Tiddl...@googlegroups.com
Here is a proof-of-concept macro I wrote to see if I can get it working:

config.macros.tiddlerName = { text: "" };
config.macros.tiddlerName.handler = function(place,macroName,params,wikifier,paramString,tiddler)
var string = tiddler.getAttribute('tiddler');
wikify(string, place, null, null);
}


It errors-out with 'tiddler is undefined.

-- 
Bobman

FND

unread,
Jul 21, 2009, 2:57:36 PM7/21/09
to Tiddl...@googlegroups.com
N.B.:
Strictly development-related issues are better discussed on the dev group:
http://groups.google.com/group/TiddlyWikiDev/
You're more likely to get competent help there.

> Here is a proof-of-concept macro I wrote to see if I can get it working:

> [...]


> It errors-out with 'tiddler is undefined.

For me that results in the following error:
Error while executing macro <<tiddlerName>>:
TypeError: tiddler.getAttribute is not a function

Either way, the macro is being passed a *store* tiddler (JavaScript
object), not a *story* tiddler (DOM element).
The best way to get a feel for this is to inspect the object with Firebug:
console.log(tiddler);

HTH.


-- F.

Bob Paige

unread,
Jul 21, 2009, 3:23:52 PM7/21/09
to Tiddl...@googlegroups.com
Oops. I figured I was getting close to that line. I'll inquire over there.

:)

-- 
Bobman
Reply all
Reply to author
Forward
0 new messages