Hi,

I'm looking for something like this.  When we use Template Toolkit,
there is a template, a data structure, and the text output by template
engine.  Now I want to take the output text and the template, and have
a parser to extract the data structure according to the template.

For example, given the following plaintext (foo.txt):

    Hello, Peggy.  You have 2 messages:

      Liz     Re: the program you asked
      Alice   I GOT IT!!!

And the following template (foo.tpl):

    Hello, [% name %].  You have [% messages.length %] messages:

    [% FOREACH m=messages %]
      [% m.sender_name %]     [% m.subject %]
    [% END %]

I'd like to do this:

    use Parse::Template;
    $parse = new Parse::Template;
    $parse->process('foo.tpl', 'foo.txt');

    # $parser->process returns the data structure:
    #
    # {
    #    name=>'Peggy',
    #    messages=>[
    #      { sender_name => 'Liz', subject => 'Re: the program you asked' },
    #      { sender_name => 'Alice', subject => 'I GOT IT!!!' },
    #    ],
    # }


I must have seen a module to do it long time ago (and I was thinking,
"wow, great idea!") But now I can't find it anymore.

Any help?



_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to