You can not get the text of the current tiddler because that causes an infinite recursion problem.
You try to fetch the content of the current tiddler, but because the current tiddler text contains your macro tiddlywiki tries to get “expand” the macro which in turn tries to get the text again and again.
When doing normal tiddlywiki transclusions the core takes care of avoiding this kind of situations by showing you an error message, but in pure macros you don’t have this “help”.
What are you trying to achieve? The best solution may be a different one depending on your use-case.
Thank you for the response. I am trying to make a Table of Contents plugin. So I want to look at the headings and generate the list and hopefully direct links to them.
I’m new too so I’ll only say I know this works for a javascript macro. It shows up in the browser developer tools (I’m in Chrome) under the source tree. One can actually set breakpoints and do the same debugging and variable inspection that’s possible with standard web programming.
I’m just about to poke around in the $tw object.