On 05-05-2010 at 14:26:08 Robert Goldsmith <rgoldsm...@names.co.uk> wrote:
Just a quick one. Could someone tell me how to reference a variable
defined within a metal macro from within a slot?
You can't. Slots aren't filled on demand, but in advance before the macro
is called (slot in a loop would repeat the same content over and over).
In particular, I'd like to define a macro that generates a calendar grid
of days and then use a slot to provide varying content to be rendered
within the 'day' cells. I am trying to do this as a macro accepting an
array and looping through the array content. This works fine but when I
then try to split out the cell content into a slot, I receive errors
that I can't access the current loop value (or, by my understanding, any
other variables defined within the metal macro) from the slot.
A quick (very simplified) example...
The macro block (in macro.xhtml):
<tal:block tal:repeat="currentDay days">
You could change:
And instead of filling slot, define macro for day:
<tal:block tal:define="days monthDays; calendarDayMacro
PHPTAL mailing list