Apache::Wyrd::Interfaces::Mother - Reverse-parsing interface for Wyrds
If the enclosing Wyrd is the parent of an enclosed wyrd, the Mother interface allows "children" of a Wyrd to be processed AFTER the parent, reversing the normal flow of interpretation and calling the
This is used, for example, in Forms, where the
Apache::Wyrd::Form will need to alter values in the enclosed
Apache::Wyrd::Inputs and similar children after they have been parsed.
To accomplish this, every child must call the
register_child method. This will give the mother a private attribute
_children containing an arrayref to the child objects.
When the mother has manipulated its children via access to the
_children arrayref, it calls
_set_children to output the children to their place within the enclosed HTML. For this to function, each child must have a
final_output method to call, and must output
'$:'+ the id returned by the
_register_child method. Typically this is done with the following code:
$self->_data('$:' . $id);
(format: (returns) name (accepts))
Prior to producing output, the mother should, assuming
_datacontains the enclosed data at the time, call
_set_childrento perform the delayed processing of its children. Set children operates on the _data attribute, so be sure the children's placemarkers are in _data before calling this method.
When used with the optional argument, that attribute is assumed to be the storage place for the children rather than _data.
Adds the child to the mother's
_childrenattribute and returns a placemarker string the mother will use to find it. Every child of the mother should call register_child. In so doing, it should set it's output (usually during the
_generate_outputphase) with the string "$:idname" where idname is the id returned by this method. It can do this in any way it likes, for example by replacing it's _data attribute, as long as it's
outputmethod returns this value.
Hook method for performing some action on or using each child.
_child_hash are reserved by this interface.
Children must ensure that the '$:' string before the ID string is not interpreted by perl as the $: variable, i.e. use single quotes/q() around the string. See
Barry King <firstname.lastname@example.org>
Copyright 2002-2007 Wyrdwright, Inc. and licensed under the GNU GPL.
See LICENSE under the documentation for