Stories
Slash Boxes
Comments
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)

dws
  (email not shown publicly)
http://www.davewsmith.com/

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);
...
<TMPL_IF EXAMPLE> HTML fragment </TMPL_IF>

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.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.