Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

dws (341)

  (email not shown publicly)

Journal of dws (341)

Friday March 07, 2003
02:46 PM

Designer-friendly HTML::Template templates

[ #10945 ]
The Silicon Valley Perl Mongers did lightning talks earlier this week. It was short notice, attendance was very light, and only a few people had talks. Still, it was a fun evening. Fun enough that we'll repeat it (with more warning, I hope).

I gave two short talks. One was on the rather evil trick of using nested regexes to handle a class of substitution problems. The other talk was more practical, dealing with the challenge of sharing responsibility for templatized pages with a non-programmer designer. In brief, the idea is to make templates directly viewable in browsers, so that designers can verify their designs and design changes without having to run a tool to expand the template. (Such tools always seem to be broken at the moment a designer needs them.) From the development perspective, the designer leaves "example" fragments in the code that need to be replicated by some use of the template.

The technique for isolating "example" fragments such that they're visible when the template is viewed in a browser, but invisible when the template is expanded, is pretty simple.

$template->param(EXAMPLE => 0);

The browser ignores the unknown tags, and shows the fragment. When the template is expanded, the fragment goes away.

The second step--replacing the fragement with other stuff--is also pretty simple.

$template->param(BEGIN => "-->);
$template->param(END => "<--");
<!-- <TMPL_VAR BEGIN> template stuff <TMPL_VAR END> -->

The template stuff is invisible to the browser, but visible when expanded.

Then it's a *cough* simple matter of keeping development changes in sync with design changes.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.