Adriano Ferreira > Data-Template-0.0005 > Data::Template

Download:
Data-Template-0.0005.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.0005   Source  

NAME ^

Data::Template - Generate data structures from templates

SYNOPSIS ^

    use Data::Template;

    $dt = Data::Template->new();
    $tt = {
        who => 'me',
        to => '${a}',
        subject => 'Important - trust me',
        body => <<'BODY',
    
            When I was ${b}, I realized that
            I had not ${c}. Do you?
    BODY
    };
    $data = $dt->process($tt, { a => 'someone', b => 'somewhere', c => '100$' });

DESCRIPTION ^

Templates usually convert text templates to text. This module goes further by converting data structure templates to data structures.

Beyond that, nothing new. I am lazy and the Template Toolkit is here today - so I use it.

The current implementation handles hash refs, array refs and non-ref scalars (strings). The processing rules are:

(The implementation so far is so naïve that causes laughs. But laughing may be good.)

FUNCTIONS

new

A constructor. Wow!

process
    $data = $dt->process($tt, $vars)

Process the templates generating a new data structure. It dies on errors (or not - see constructor parameters to come soon).

process_s

For processing a scalar.

process_a

For processing an array.

process_h

For processing a hash.

EXAMPLES ^

Soon.

SEE ALSO ^

Template - as this is used to process the text templates.

Please reports bugs via CPAN RT, http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data-Template

AUTHOR ^

A. R. Ferreira, <ferreira@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright (C) 2006-2007 by A. R. Ferreira

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: