[Petal] new() or process() on a string rather than a file?

Corey corey_s at qwest.net
Wed Sep 27 03:03:58 BST 2006


Subject says it all - what if I have a string that I'd like to process
using Petal? How do I do so?  It appears that Petal only supports
processing external files?

What if my template was stored in a database, then retrieved with
the DBI into a variable?

It seems that it would be extremely useful to be able to do something
along the lines of:

# or assume this came from some other datasource, like a database
$input = '
<html xmlns:tal="http://purl.org/petal/1.0/">
    <body tal:content="bar">Dummy Content</body>
</html>
';

# obviously, this does not work:
$template = Petal->new( $input );

$output = $template->process ( bar => 'BAZ' );

print $output;


Which would print:

<html>
   <body>BAZ</body>
</html>


Did I miss what I'm looking for in the docs somewhere?  Or if not, is there
some specific reason why processing a string rather than a file is not made
possible via Petal?


Many thanks!

Corey




More information about the Petal mailing list