RE: [Templates] Is this a job for TT?

[prev] [thread] [next] [Date index for 2005/02/22]

From: Ron Pero
Subject: RE: [Templates] Is this a job for TT?
Date: 18:41 on 22 Feb 2005
Thank you Mark. The suggestion about ParseExcel is an excellent one and I
intend to use it, for this project perhaps, and for others also. Now that
the weekend is past I will be digging into this project. Since no one else
has suggested any other way to access the data like I need, I assume TT
itself does not have such a means. So using perl to read in the data sounds
like a given. Then I will probably use TT to create the html pages, although
that ends up being a trivial part of the process.

If it becomes clear to me, I may end up writing a filter that does break a
data file into the equivalent of several files, creating an html page for
each section.

Or perhaps there are already modules to facilitate reading specialized data
formats...

Hmmm. Randal Schwartz spoke at the Seattle PUG about a month ago, and he
mentioned that Damian Conway has an idea to create a repository of grammars
that can be used by Parse::RecursiveDescent (or whatever) against various
structured and semi-structured bodies of data. Sounds interesting.

Ron

> -----Original Message-----
> From: Thomas, Mark - BLS CTR [mailto:Thomas.Mark@xxx.xxx]
> Sent: Friday, February 18, 2005 6:19 AM
> To: 'tt@xxxxxxxx.xxx'; templates@xxxxxxxxxxxxxxxx.xxx
> Subject: RE: [Templates] Is this a job for TT?
>
>
> I happen to have lots of identical situations (Excel input; TT-templated
> pages out)
>
> I'll let others with more TT expertise tell you how to do it
> entirely in TT,
> but I think you would require some perl anyway, either in a
> driver or in the
> templates themselves.
>
> One thing I'd do is get rid of the copy/paste step. I use
> SpreadSheet::ParseExcel to directly extract information from the
> spreadsheets. This is much more convenient and powerful--it supports a lot
> more than copy/paste can (multiple worksheets, cell formatting, document
> settings, etc). I have a web application where people upload their Excel
> file and it instantly produces multiple HTML files.
>
> At the parse stage you can fill out a data structure like this:
>   @groups = (
>     {
>       id        => 1,
>       name      => 'Group 1',
>       html      => 'group1.html',
>       broadcast => 'group1@x.xxx',
>       members   => [ 'me@x.xxx', 'you@x.xxx' ],
>     },
>     ...
>   );
>
> Then you just do something like
>   $tt->process($_->{html}, $_) for @groups;
> and the templates would be trivial.
>
> This is a simplified version of how I do it. The web application I was
> talking about actually takes input in several formats, normalizes
> them to a
> perl data structure, and matches them with templates created by
> non-programmers (which are added/viewed/edited through this app).
>
> Perhaps this will help you.
>
> - Mark.
>
> > -----Original Message-----
> > From: templates-admin@xxxxxxxxxxxxxxxx.xxx
> > [mailto:templates-admin@xxxxxxxxxxxxxxxx.xxx] On Behalf Of Ron Pero
> > Sent: Friday, February 18, 2005 2:33 AM
> > To: templates@xxxxxxxxxxxxxxxx.xxx
> > Subject: [Templates] Is this a job for TT?
> >
> >
> > There's a task I currently do with perl, but would like to
> > see if TT can do the job more easily.
> >
> > Although I've used TT just a little bit, I am very familiar
> > with templating in general, and have the Badger book, so I'm
> > just looking for a pointer on how to get started with this,
> > and whether TT can even do it.
> >
> > Here's the mission.
> >
> > Start with a text file, which is copied and pasted from an
> > Excel spreadsheet, so it is tab delimited. In this case each
> > line contains a name and email and other info, and a couple
> > headings, and lines of hyphens. The perl script reads the
> > file line by line and creates html pages from it.
> >
> > The Datafile plugin would seem like a good candidate, but
> > here's the catch: the text file contains several lists within
> > the single file, each of which gets made into its own html
> > page. Correct me if I'm wrong, but I believe Datafile has no
> > mechanism to read several different lists within the same
> > file, stopping at the end of each list, letting TT do
> > something, then starting the next list.
> >
> > Here's a simplified version of the text file.
> >
> > GROUP 1
> >
> > Broadcast E-Mail Address: group1@x.xxx
> >
> > me	me@x.xxx
> > you	you@x.xxx
> > he	he@x.xxx
> >
> > -------------------------------------
> >
> > GROUP 2
> >
> > Broadcast E-Mail Address: group2@x.xxx
> >
> > he	he@x.xxx
> > she	she@x.xxx
> > it	it@x.xxx
> >
> > -------------------------------------
> >
> > GROUP WHATEVER
> >
> > Broadcast E-Mail Address: group3@x.xxx
> >
> > we	we@x.xxx
> > you	you@x.xxx
> > they	they@x.xxx
> >
> > So, each of these lists becomes an html page, with
> > href="mailto:me@x.xxx"; and so forth. The perl script "knows"
> > to end the list and start the new one based on the hyphens
> > and the formatting of the headings.
> >
> > Is this a job for TT? If so, what is the trick?
> >
> > It pretty much needs to be a simple text file like this.
> > People in the office edit the data now and then in Excel,
> > then turn it over to me to convert into nice looking html pages.
> >
> > Thanks,
> >
> > Ron
> >
> > --------------------------------------------
> > My mailbox is spam-free with ChoiceMail, the leader in
> > personal and corporate anti-spam solutions. Download your
> > free copy of ChoiceMail from www.choicemailfree.com
> >
> > _______________________________________________
> > templates mailing list
> > templates@xxxxxxxxxxxxxxxx.xxx
> > http://lists.template-toolkit.org/mailman/listinfo/templates
> >
>
>
>
>

--------------------------------------------
My mailbox is spam-free with ChoiceMail, the leader in personal and corporate anti-spam solutions. Download your free copy of ChoiceMail from www.choicemailfree.com

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] Is this a job for TT?
Ron Pero 07:33 on 18 Feb 2005

RE: [Templates] Is this a job for TT?
Thomas, Mark - BLS CTR 14:18 on 18 Feb 2005

RE: [Templates] Is this a job for TT?
Ron Pero 18:41 on 22 Feb 2005

Generated at 08:55 on 15 Mar 2005 by mariachi v0.52