Mark Blythe > HTML-Chunks-1.55.1 > HTML::Chunks::Super

Download:
HTML-Chunks-1.55.1.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 1.01   Source  

NAME ^

HTML::Chunks::Super - Chunks with superpowers

VERSION ^

1.0

DESCRIPTION ^

The mutant spawn of HTML::Chunks, this module has all of the abilities of its parent plus additional emerging superpowers. The first enhancement to be added is conditional processing. For full chunk documentation, please see HTML:::Chunks. Only HTML::Chunks::Super enhancements will be discussed here.

CONDITIONAL PROCESSING ^

While conditional processing does indeed blur the lines between layout/markup and actual programming logic, it can be very powerful when used sparingly and appropriately. We urge you to use this ability only for simple display logic, keeping the chunk side of life mostly pure and uncomplicated. With great power comes great responsibility. :-)

That warning aside, here is the extended chunk syntax:

 <!-- IF condition -->
 normal chunk stuff
 <!-- ELSIF condition -->
 more chunks
 <!-- ELSE -->
 chunky chunk of chunks
 <!-- ENDIF -->

The condition can by most any valid perl expression and will usually reference one or more chunk data elements. See the HTML::Chunks documentation for a full descripton of data elements, but as a refresher, they look like ##this## and refer to dynamic data that is merged into a chunk at run-time. For use in conditionals, you can treat them as read-only scalars.

Some example conditions

##foo##

True if data element ##foo## has a true value (in the perl sense of "true")

##foo## =~ /^bar/

True if ##foo## begins with "bar"

##foo## !~ /\W/

True if ##foo## contains no non-word characters

##num## >= 1 and ##num## <= 10

True if ##num## is between 1 and 10 inclusive

You get the idea. Most comparisons and conditions that are possible in straight perl will be possible here as well.

CREDITS ^

Created, developed and maintained by Mark W Blythe and Dave Balmer, Jr. Contact dbalmer@cpan.org or mblythe@cpan.org for comments or questions.

LICENSE ^

(C)2001-2009 Mark W Blythe and Dave Balmer Jr, all rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: