The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Decl::Semantics::Repeat - implements a repeated node

VERSION

Version 0.01

SYNOPSIS

The "repeat" node repeats its children at its own hierarchical level. It's essentially a loop at build time, a quick way to build structure based on data retrieved. The foreach/select nodes are convenient abbreviations for the long-form repeat. Whereas the repeat node has separate children for its query and repetition text and thus has a place to put parameters, code, and other things to refine the repetition process, the foreach/select nodes just treat their lines as SQL/data queries directly for brevity's sake.

defines(), tags_defined()

Called by Decl::Semantics during import, to find out what xmlapi tags this plugin claims to implement.

decode_line

The select/foreach node is the first to parse its line differently from the standard. It treats its entire line as an SQL query (or a data query, depending) - it uses the same syntax as the ^foreach/^select command in embedded Perl.

The only exception is that to make the expression of the body easier, it always uses fetchrow_hashref to retrieve the values from each row. The hash keys are then used to determine what should be replaced in the body for each child built.

parse_body

Same thing. The select/foreach node doesn't want to parse its body. Normally, we'd just mark that in build_handlers, but if we do that, we can't macroinsert the results (because there wouldn't be any body parser there, either... Yes, this was a confusing couple of hours.)

post_build

Here is where we actually do the work of instantiating our true children, based on the body given us and repeating over the results of the query passed in. The repeat body is either the direct body of this tag, or the body of the "text" tag below it, depending on whether this is a "repeat" or a "foreach"/"select" construct.

go

Finally, at runtime, we just execute by calling each of our macroinserted children. Et voila!

nodes

We override nodes to permit group shenanigans.

AUTHOR

Michael Roberts, <michael at vivtek.com>

BUGS

Please report any bugs or feature requests to bug-decl at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Decl. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

LICENSE AND COPYRIGHT

Copyright 2010 Michael Roberts.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.