> ... a bug in the core when it
> comes to the tiddler macro (and/or evaluated parameters) misbehaviing
> during TiddlyWiki startup.
During macro handling, the TWCore invokeMacro() function calls on
parseParams() so it can populate the 'params' array that is then
passed along to the specific macro handler. It is during processing
of parseParams() that evaluated parameters (i.e., {{...jscode...}})
are invoked, and their resulting values included in the params array.
Many TWCore macros (and most plugin-defined macros) rely upon
invokeMacro() to pre-parse their params. However, some macros, such
as <<tiddler>>, also call parseParams() themselves in order to perform
more advanced parameter handling, such as extracting *named*
parameters from the raw 'paramString' that is also passed to the macro
handler.
Unfortunately, re-processing the paramString also causes any evaluated
params to be RE-invoked, resulting in the double-processing that has
been observed. Of course, if the eval param is just fetching a value
(e.g., {{tiddler.title}} or {{new Date()}}), then it usually doesn't
matter if it is processed more than once. However, if the eval param
does something visible or that has a side-effect (e.g., displaying a
message or incrementing a counter), then the extra processing will
produce unexpected interactions and/or incorrect results.
Fortunately, there *is* a configuration-based fix for it! Some time
ago (TW2.5.x), I submitted a core patch that can be used to
selectively disable the 'pre-parsing' of parameters for any given
macro by setting
config.macros.nameOfMacro.noPreParse=true;
When set, invokeMacro() skips the call to parseParams() and passes an
empty 'params' array to the macro. It is then left to the handler
itself to invoke parseParams() to process the params as needed. Thus,
because the tiddler is already doing it's parserParams() procesing,
the macro doesn't rely upon the 'params' array, and we can safely
disable the pre-parsing for that macro by setting:
config.macros.tiddler.noPreParse=true;
Note: this setting *could* be included in the TWCore by default, but
it was decided to leave the existing behavior unaffected out of an
abundance of caution about backward-compatibility. However, as far as
I can determine, there is *no* use-case for which disabling pre-
parsing for the <<tiddler>> macro would cause a problem.
enjoy,
-e