On Wed, Aug 06, 2003 at 01:44:35PM -0500, Richard Tietjen wrote:
> > From: "pm5" <[EMAIL PROTECTED]>
> > To: [EMAIL PROTECTED]
> > Date: Wed, 6 Aug 2003 17:23:18 +0800
> > Subject: [Templates] Parsing text by 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 %]
> 
> 
> You could extract delimited data from a text file with Datafile, as
> documented below.  and figure out the number of messages in the
> calling template automatically.
> 

Thanks.  But I guess I want more convenient ways to make a generic
parser.  I was thinking when parsing a text file or web page, can I
just grab the target file, replace some text inside with expressions 
and make it a template, and have a parser engine to dig out these
values.

The kind of parsers generated by this approach would be quite limited,
but it makes jobs like parsing text files or web pages (which I do
oftentimes) a lot easier.


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

Reply via email to