On Jan 16, 10:49 pm, passingby <[email protected]> wrote:
> The 'tiddler' object is used in fET in where condition. I tried to
> find this object in the DOM using firebug, and I did find a 'tiddler'
> object under Window object but it represented the latest tiddler
> opened in display area. So how does this work? where are other
> tiddlers residing, the open ones and not yet opened ones? What exactly
> happens when a tiddler is opened, is an HTML Div created as well as a
> javascript object?
The entire set of tiddlers -- opened or unopened -- is stored in the
TW core's "store" object. You can use 'getTiddler()' to retrieve any
tiddler, by title:
var tid=store.getTiddler("TiddlerTitle","default text");
note: the 2nd paramter is 'fallback' text to be used if the tiddler
doesn't exist.
When a tiddler is opened, the TW core creates and inserts a DOM
element, "#tiddlerTiddlerTitle" within the "#tiddlerDisplay"
container. The core then renders the ViewTemplate (HTML syntax) into
that DOM element, and then processes any special extended TW syntax
defined within that template.
When the following ViewTemplate HTML syntax is processed:
<... macro="view text wikified" ...>
the TW core's wikify() engine is triggered, which processes the
tiddler.text by matching patterns of wiki-formatting syntax and
rendering the corresponding DOM element output.
When wikify() recognizes the embedded macro syntax (i.e, "<<macroName
param param ...>>"), it calls on invokeMacro(), which automatically
sets a *global* window.tiddler variable to point to the current
tiddler object that is being rendered. This enables the macro's
parameter processing to use "evaluated parameters" that reference
values within that tiddler object, like this:
<<someMacro ... {{tiddler.title}} ...>>
Note: prior to TW2.4.3, you needed TiddlyTools' CoreTweaks #444, which
added the global window.tiddler (and window.place) variables to the
invokeMacro() function. Starting with TW2.4.3, this functionality was
added to the core.
After the calculation and substitution of evaluated parameters is
complete, invokeMacro then passes the parameter values onward for
further rendering by the appropriate macro handler function:
config.macros.someMacro.handler(place,tiddler,params,wikifier,paramString,tiddler)
Note: Typically, the tiddler param passed to the macro handler
function is the same as the 'current tiddler' that is being rendered.
However, when you use the "<<tiddler TiddlerName>>" macro to
*transclude* content from other tiddlers, the 'tiddler' param that is
passed to any macros *within the transcluded tiddler* will reference
that transcluded tiddler, rather than the outer 'current' tiddler that
is being rendered.
Finally, when the fET macro handler -- config.macros.forEach.handler()
-- processes tiddlers, it automatically sets a *locally-scoped*
tiddler variable that only applies *within the context of the fET
syntax*, and allows you to reference one tiddler at a time from the
list of matching tiddlers.
While all these different usages may seem a bit confusing, the result
is that, at each point along the way, a reference to 'tiddler'
produces the expected results (in terms of *which* tiddler it actually
refers to).
Hope this helps,
enjoy
-e
Eric Shulman
TiddlyTools / ELS Design Studios
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/tiddlywiki?hl=en.