AxKit2::XSP::SimpleTaglib 1.1 review

Download
by rbytes.net on

AxKit2::XSP::SimpleTaglib is an alternate XSP taglib helper. SYNOPSIS package Your::XSP::Package; use AxKit2::XSP::Sim

License: Perl Artistic License
File size: 632K
Developer: J?rg Walter
0 stars award from rbytes.net

AxKit2::XSP::SimpleTaglib is an alternate XSP taglib helper.

SYNOPSIS

package Your::XSP::Package;
use AxKit2::XSP::SimpleTaglib;

... more initialization stuff, start_document handler, utility functions, whatever
you like, but no parse_start/end handler needed - if in doubt, just leave empty ...

sub some_tag : XSP_attrib(id) XSP_attribOrChild(some-param) XSP_node(result) XSP_keepWhitespace {
my ($tag, $attr, $stack, $struct) = @_;
return do_something($$attr{'some-param'},$$attr{'id'});
}

# old style usage no longer documented, but still supported

This taglib helper allows you to easily write tag handlers with most of the common behaviours needed. It manages all 'Design Patterns' from the XSP man page plus several other useful tag styles, including object-like access as in ESQL.

Simple handler subs

A tag "" will trigger a call to sub "foo" during the closing tag event. What happens in between can be configured in many ways using Perl function attributes. In the rare cases where some action has to happen during the opening tag event, you may provide a sub "foo__open" (double underscore) which will be called at the appropriate time. Usually you would only do that for 'if'- style tags which enclose some block of code. 'if'-style tags usually also need the XSP_compile flag.

Contrary to the former behaviour, your tag handler is called during the XSP execution stage, so you should directly return the result value. The XSP_compile flag is available to have your handler called in the parse stage, when the XSP script is being constructed. Then, it is the responsibility of the handler to return a Perl code fragment to be appended to the XSP script.
As a comparison, TaglibHelper subs are strictly run-time called, while plain taglibs without any helper are strictly compile-time called.

Warning: The old usage is still fully supported, but you should not use it anymore. It may become deprecated in a future release and will be removed entirely afterwards. Porting it to the new style usage is quite easy: remove the line reading "package your-taglib::Handler;", then prefix "XSP_" to all Perl attributes (e.g., "childStruct" becomes "XSP_childStruct"), and add "XSP_compile" to every handler sub. If after your refactoring some handler sub doesn't carry any Perl attribute anymore, add a plain "XSP" Perl attribute.

Perl attributes without the 'XSP_' prefix cause a warning (actually, sometimes even two, one from Perl and one from SimpleTaglib), as lower-case Perl attributes are reserved for Perl itself.

Requirements:
Perl

AxKit2::XSP::SimpleTaglib 1.1 search tags