Band.pm - Yet another perl-based HTML Template technology
Perl CGI module useful for merging HTML from designers with dynamic perl
data structures, using a single <--band--> tag that defines conditional and
repeating "bands" of HTML with nested namespaces for scalar variable
interpolation.
Band Objects allow you to define define tree structures (nested bands)
within html template files that contain conditional or repeatable html
"bands" which include simple scalar variables expanded at run time.
# instantiate a new Band object
$myskin=new Band;
# initialize it with a template file (html with <!--band--> tags)
$myskin->template(file=>$file)
or die "error setting template from file: '$file' - ". $myskin->error;
# parse the template (validate the template syntax)
$myskin->parse or die "error parsing template - ". $myskin->error;
# assign a hash of "global" tokens to template
$myskin->bandtoken( %token)
or die "can't set global band token - ".$myskin->error;
# define a list of hashes to populate a repeating band
$rows=({%row1hash}, {%row2hash}, ...);
# assign the named rowset to the the template
$myskin->rowset(myrows, @rows) or die "can't set 'myrows' list - ".$myskin->error;
# print the merged results
print "Content-Type: text/html\n\n",
$myskin->merge ;
# to debug your template's stucture, play with this:
print "<pre>extracting</pre>";
print "Content-Type: text/html\n\n",
$myskin->source(
with_band_tags => 1,
hide_implied_tags => 1,
htmlify => 0,
testresults => 1,
# indent => 1,
# show_scope=>1,
# show_tokens=>1,
# pretty =>1,
merge =>1,
conditional => 1,
);
Band.pm Version 1.00 - Yet another perl-based HTML template technology
Copyright (C) 1999, 2000 Power Data Development
Support, upgrades and custom implementations are available from
Power Data Development http://power-data.com
Please direct inquiries about this software to program@power-data.com
General inquiries may be sent to info@power-data.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Or you can grab a copy from http://power-data.com/lgpl-license.html