in reply to Re^2: I am about to write my very own templating module..
in thread I am about to write my very own templating module..
Hmmm... if you can install one module, why can't you install 20? I would expect this to be an all or nothing situation. If you can drop one module in your local directory, you can drop all of TT there.
I embarked in working with HTML::Template. But the syntax is not well readable
I'm not a fan of that syntax either. I definitely prefer the aesthetics of the TT syntax.
There is no special case to deal with newlines around the <tmpl_*> tags, so you can't put them on a line of their own if you want the output to look neat and tidy.
TT handles that, as do some of the others.
The templating module I want would offer powerful interpolation syntax but not a bit more power in highlevel constructs than necessary.
But no one is twisting your arm and telling you to use the full syntax of TT! Just use the part you want. If you find out you need more of it later on, it will be there for you.
1) fetch data, build list
2) run filters over list to provide the template logic; variables get changed, added, deleted etc per record here
3) interpolate data into template
All non-trivial modules I have seen try to integrate step 2 and 3 inside the template.
Hmmm. I don't think I understand these steps. The pipeline model is all about doing all of your data munging before running the template. The template only has display logic in it, and doesn't modify any data.
Now, you could say TT2 allows me to do it my way even if it offers more power than I want. But besides being awkward to use when you cannot install modules, to me it feels like "the tail wagging with the dog" as they say in Germany. Total overkill. I do not need a module that comes in 20-odd files incl XS, compiles my template to interpolate it, and can make coffee and bake cake to boot.
The XS is optional, of course. TT is fairly big. However, size is only a problem when it does not fall within your required limits for disk space, RAM, speed, and ease of use. I don't use half of the capabilities that TT provides, but I love the fact that when a designer comes to me and says "I want to display these search results in two columns" I can say "Here's the TT table plugin" and not have to write it myself. I've had experiences like that over and over with TT.
Back when I was a Perl newbie, I did write my own templating system. I actually wrote a couple of them. (In my defense, TT didn't exist then.) I started out really simple, but I ended up with a mess because people kept requesting features like columnizing lists, or slightly fancier boolean conditionals, or date formatting, etc. That's why I get so suspicious when people complain that the existing modules have too many features.
I was seriously about to go with CGI::FastTemplate - small, simple, clean concept written in a no-installation-required single Perl-only module. Except I had written something very similar myself for a previous (unspeakbly ugly) script and have come to despise the templatelet mess it reinforces.
Glad to know I'm not the only one who feels that way.
Say I wanted to modify an existing module rather than writing one from scratch. Where would you propose that I start?
The closest to what you are suggesting is Text::Templar, but I don't know how easy it would be to extend.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: I am about to write my very own templating module..
by Aristotle (Chancellor) on Sep 27, 2001 at 04:15 UTC | |
by perrin (Chancellor) on Sep 27, 2001 at 08:29 UTC | |
by Aristotle (Chancellor) on Sep 27, 2001 at 13:02 UTC |