Text::PORE is a Perl Object Rendering Engine.
pore
intr.v.
1. To read or study carefully and attentively
The American Heritage® Dictionary of the English Language, Fourth Edition
SYNOPSIS
How to use PORE to render Perl objects.
use Text::PORE::Template;
use Text::PORE::Object;
The Perl object to be rendered:
$obj = new Text::PORE::Object('name'=>'Joe Smith');
@chilren = (
new Text::PORE::Object('name'=>'John Smith', 'age'=>10, 'gender'=>'M'),
new Text::PORE::Object('name'=>'Jack Smith', 'age'=>15, 'gender'=>'M'),
new Text::PORE::Object('name'=>'Joan Smith', 'age'=>20, 'gender'=>'F'),
new Text::PORE::Object('name'=>'Jim Smith', 'age'=>25, 'gender'=>'M'),
);
$obj->{'children'} = @chilren;
The template file (demo.tpl):
Name: < PORE.render attr=name >
Children:
< PORE.list attr=children >
< PORE.render attr=name >, < PORE.render attr=age >, < PORE.if
cond="gender EQ 'M'" >Male< PORE.else >Female< /PORE.if >
< /PORE.list >
The code that renders the object using this template:
#
# create a template
#
$tpl = new Text::PORE::Template('file'=>'demo.tpl');
#
# render the object using the template
# the result is printed to STDOUT
#
my $fh = new FileHandle();
$fh->open('>& STDOUT');
Text::PORE::render($obj, $tpl, $fh);
$fh->close();
The rendering result:
Name: Joe Smith
Children:
John Smith, 10, Male
Jack Smith, 15, Male
Joan Smith, 20, Female
Jim Smith, 25, Male
Product's homepage
Requirements:
· Perl