Apache::Wyrd::Interfaces::Mother - Reverse-parsing interface for Wyrds
NONE
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 output method.
output
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.
Apache::Wyrd::Form
Apache::Wyrd::Input
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.
register_child
_children
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:
_set_children
final_output
'$:'
_register_child
$self->_data('$:' . $id);
(format: (returns) name (accepts))
Prior to producing output, the mother should, assuming _data contains the enclosed data at the time, call _set_children to 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.
_data
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 _children attribute 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_output phase) 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 output method returns this value.
_generate_output
_process_child
Hook method for performing some action on or using each child.
The methods _name_child, _generate_id, _set_children, and _child_hash are reserved by this interface.
_name_child
_generate_id
_child_hash
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 Apache::Wyrd::Interfaces::Setter.
Apache::Wyrd::Interfaces::Setter
Barry King <wyrd@nospam.wyrdwright.com>
General-purpose HTML-embeddable perl object
Copyright 2002-2007 Wyrdwright, Inc. and licensed under the GNU GPL.
See LICENSE under the documentation for Apache::Wyrd.
Apache::Wyrd
To install Apache::Wyrd, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Apache::Wyrd
CPAN shell
perl -MCPAN -e shell install Apache::Wyrd
For more information on module installation, please visit the detailed CPAN module installation guide.