tiddler macro fails with startup tiddlers

85 views
Skip to first unread message

Tobias Beer

unread,
Mar 12, 2013, 6:16:53 AM3/12/13
to tiddl...@googlegroups.com
Hi everyone, especially @Eric,

I believe I have already pointed this out a very long time ago. However, the bug that prevents the tiddler macro from running correctly with startup tiddlers seems to still lurk around. If I remember correctly, it's a problem with parsing parameters, i.e. not only does the tiddler macro get called twice but somehow the also with a wrong or even empty params array.

For an example, see...


In the tiddler title, you see FAQ » prepended to the title.

This is achieved by calling the tiddler...

...which contains nothing but...
[[$1|$2]] <<tag [[$1]] »>>

...conditionally in the ViewTemplate using HideWhenPlugin via...
<span macro='showWhenTagged FAQ'>
<span macro='tiddler DOMAIN with: FAQ FAQ'></span>
</span>

Other than using my new creation called NameSpacePlugin [1] — which I probably will — (how) can this (finally) be fixed?

Cheers, Tobias.


Jeremy Ruston

unread,
Mar 18, 2013, 8:03:56 AM3/18/13
to TiddlyWiki
Hi Tobias

Sorry for the late reply. Can you be more specific about where I can see the problem? Viewing the example you sent doesn't show anything that is obviously wrong to me.

Many thanks,

Jeremy


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Jeremy Ruston
mailto:jeremy...@gmail.com

Tobias Beer

unread,
Mar 19, 2013, 1:58:28 PM3/19/13
to tiddl...@googlegroups.com
Hi Jeremy,

Thanks for the follow up. Opening the above mentioned link you should find a tiddlyLink named [[FAQ]] before the tiddler title followed by the tag macro as a delimiter using &raquo; ...while the latter works, the tiddlyLink does not and point to [[$2]]. If you view / edit the tiddler and go back to view mode, then the tiddlyLink works, which is why I call this a startup problem.

Cheers, Tobias.

Tobias Beer

unread,
Mar 19, 2013, 2:03:09 PM3/19/13
to tiddl...@googlegroups.com
In other words, it seems that params[0] receives a value yet there is no params[>0]... assuming the tiddler macro uses a params array.

Cheers, Tobias.

Jeremy Ruston

unread,
Mar 19, 2013, 2:04:46 PM3/19/13
to TiddlyWiki
Hi Tobias - Thank you that makes sense. It would be handy to have a minimal test case to play with; did you make one in your explorations?

Best wishes

Jeremy


On Tue, Mar 19, 2013 at 6:03 PM, Tobias Beer <beert...@gmail.com> wrote:
In other words, it seems that params[0] receives a value yet there is no params[>0]... assuming the tiddler macro uses a params array.

Cheers, Tobias.

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Tobias Beer

unread,
Mar 26, 2013, 8:49:00 AM3/26/13
to tiddl...@googlegroups.com, jeremy...@gmail.com
Hi Jeremy,

A while back I created an MTC for this old discussion that I just recovered...

I have updated that site to the latest core and simplified the examples...

Let me know if you have a clue as to what is going on here.

Cheers, Tobias.

Jeremy Ruston

unread,
Mar 28, 2013, 11:41:33 AM3/28/13
to Tobias Beer, TiddlyWiki
Hi Tobias

OK, I think I've figured it out. It's easier to show the fix first. In config.macros.tiddler.handler, replace these two lines:

if(args!==undefined)
wrapper.setAttribute("args","[["+args.join("]] [[")+"]]");

with this:

if(args!==undefined)
{
args = "[["+args.join("]] [[")+"]]";
wrapper.setAttribute("args",args);
}

It seems that the issue is triggered when the transclude() method is called with array arguments, rather than a string. This fix ensures that the arguments are always given in string format.

Does this work for you?

Best wishes

Jeremy

Tobias Beer

unread,
Mar 29, 2013, 6:44:09 AM3/29/13
to tiddl...@googlegroups.com, Tobias Beer, jeremy...@gmail.com
Hi Jeremy,

Thanks for giving it a try. Unfortunately, your suggestion doesn't solve the problem but rather makes it permanent, so that it persists even after a tiddler refresh.

~

There must be a problem in some regex that matches the wrong pair of closing double square brackets, e.g.:

[[ argument 1 with [[inner square brackets|stops here =>]] not here =>]]

This certainly explains, why the first line item in ExampleTransclusion isn't even a link.

~

It seems to have something to do with the fact that — probably due to some {superfluous?!?} global refresh — all tiddlers (or just transclusions) are always rendered twice on startup and that the first time. The important bit, however is, that the arguments are passed to the tiddler macro handler during the first round as an array but the second time as string  — which is when it fails — with readBracketedList wrongly splitting the string into a number of arguments rather than just one (see example above).

~

Ok, so here are the different call stacks, the two from startup and the third after I was in edit mode and escaped out of it.

call-stack on startup, 1st time...

call-stack on startup — 2nd time...

call-stack after refresh...

~

Does TW5 handle (parsing) parameters differently? The output of parseParams has a bit of an awkward feel to it, in German we would probably be inclined to call it an eierlegende Wollmilchsau... a pig laying eggs, also giving milk and wool.

Cheers, Tobias.

Tobias Beer

unread,
Mar 29, 2013, 7:02:24 AM3/29/13
to tiddl...@googlegroups.com, Tobias Beer, jeremy...@gmail.com
I have added another minimalistic example that illustrates how the error is provoked with params containing double square brackets...

http://startuptransclusions.tiddlyspot.com/index.html#Brackets

Cheers, Tobias.
Reply all
Reply to author
Forward
0 new messages