TiddlyWiki.org

Ticket #134 (new enhancement)

Opened 2 years ago

Last modified 6 months ago

Give access to the "tiddler" when evaluating macro parameters (e.g. {{tiddler.title}})

Reported by: UdoBorkowski Assigned to: JeremyRuston
Priority: minor Milestone: unscheduled
Component: core Version:
Severity: high Keywords:
Cc:

Description

See post by SimonBaird?

Change History

06/10/06 16:25:13 changed by JeremyRuston

  • milestone changed from 2.2 to unscheduled.

This isn't particularly straightforward to do. The problem is that the parseParams() function doesn't know what tiddler context it is being called from - and indeed it may not be from within a tiddler at all, in the case of using parseParams() to process the # part of the URL.

03/02/08 00:13:35 changed by EricShulman

See http://www.TiddlyTools.com/#CoreTweaks

Add to invokeMacro():

function invokeMacro(place,macro,params,wikifier,tiddler) {

var here=story.findContainingTiddler(place); window.tiddler=here?store.getTiddler(here.getAttribute("tiddler")):null; window.place=place; ...

}

note use of findContainingTiddler(), rather than using passed-in 'tiddler'. This ensures that the window.tiddler value represents the current rendered tiddler, not the tiddler that contained the actual macro source (which may have been transcluded into the current tiddler.)

Note also assignment of window.place=place... this permits macros to evaluate parameters that can perform DOM-relative references to, for example, read the state of a checkbox contained within the same rendered tiddler content in order to conditionally set the macro parameter value based on that checkbox state.