I wrote a simple program for the designers to use:
------------------------------------------------------
#!/usr/bin/perl
$|++;

use CGI;
use HTML::Template;
require "local.lib";     # templateroot and docroot are stored here.

$query = new CGI;

$template = new
HTML::Template(filename$query->param(template),path=>[$templateroot,$docroot
],associate=>$query);

print $query->header(),$template->output();
----------------------------------------------------------
When called with parameters that match variables in the page, the variables
are filled in.  Otherwise they are blank.  This gives the designer the warm
fuzzy that the page DOES work and allows them to see their creation with
data filled in so they can check formatting.

This would be called like:
/cgi-bin/showTemplate.pl?last_name=Jackson&first_name=keith

It works for us.


Keith Jackson
Chief Geek
Interactive Media Group
www.eyemg.com
330.434.7873
_____Note our new address__________
190 N. Union St.
Suite 300
Akron, OH 44304

-----Original Message-----
From: Aaron J Mackey [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 13, 2001 6:22 PM
To: [EMAIL PROTECTED]
Subject: [htmltmpl] "preview" data for templates

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi, I'm new on the list.  Is there an archive somewhere?

Here's my question/thought/proposal:  I've worked with HTML::Template for
some time now, always had good experiences.  I've recently been working
with an HTML designer, and "teaching" him not to trample my carefully
constructed HTML::Template tags has been difficult, because he keeps
wanting to put in some "real data" that he can see as he designs forms and
whatnot.  When he does type in his real data, he either a) deletes the
HTML template tags (somehow expecting them to reappear when I get the file
back), b) puts in a VALUE="foobar" attribute within the tag, expecting it
do something when he looks at it in DreamWeaver or whaterver, or c)
just writes "foobar" next to the tag (I should note that I use the HTML
comment form of tags, so they don't show up when you view them, and don't
cause issues in form data <input value="<!-- TMPL_VAR NAME-->"> usages).

So, that got me to thinking about having a way for me to include "preview"
data that could be seen while developing the template in an HTML editor,
that could be programmatically stripped during execution.  The filter
mechanism sounds good (say, to strip out <!-- TMPL_PREVIEW --> nested
text), but it also seems like I have to type alot for
that:

<table><tr><td>
<!--TMPL_VAR NAME=DATA><!--TMPL_PREVIEW -->foobar<!-- /TMPL_PREVIEW -->
</td></tr></td>

There's also the fear that my intrepid HTML designer will simply move the
"foobar" element around the page, without bringing along the other tags.

I've thought (a little) about this scenario:

<table><tr><td>
<!-- TMPL_VAR NAME=DATA -->
</td></tr></table>

then in my .cgi:

$template->param(DATA => $foobar);
$template->print_to(\*STDOUT);

Then, at the command line:
> perl -MHTML::Template=PREVIEW ./myscript.cgi
[ no output ]

Now the template looks like:

<table><tr><td>
<!-- TMPL_PREVIEW TYPE=VAR NAME=DATA-->foobar<!-- /TMPL_PREVIEW -->
</td></tr></table>

Now at least the "foobar" is together with all of it's tag (i.e., there's
no separate TMPL_VAR tag to also be worried about).

Of course, to use the template now, either a) HTML::Template would have to
also look for TMPL_PREVIEW tags, and act accordingly, or b) there'd need
to be a reverse perl -MHTML::Template=UNPREVIEW mechanism.

I haven't entirely thought out what would happen in loops ... Maybe only
the first iteration through the loop would happen during PREVIEW, just to
get one line of data ... or maybe all the iterations would happen, and the
loop itself would be PREVIEW-tagged so that the multiple iterations could
be removed later.

And then all the other tags throw my mind into a tizzy: <TMPL_ODD>, etc.
Maintaining those while still offering a "preview" that doesn't require a
web browser and connectivity (hah, you thought I hadn't thought of the
obvious!)

Thanks for any insight,

- -Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (OSF1)
Comment: For info see http://www.gnupg.org

iD8DBQE8GTgtt6Sp9Om+GYMRAjobAJ9Uuebo39C6Gsm/N5/pKJTiLygtfgCfeXLG
RzFlgLolaWF0TtDziuY1+i8=
=6TIC
-----END PGP SIGNATURE-----


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to