Falled into the trap: Template::Perlish

polettix on 2008-04-08T00:23:14

So I finally falled into the trap - I wrote a templating system: Template::Perlish. A very basic one, just giving you means to put some variables here and there, and use Perl for all control structures.

The thing I love about it is that I needed it. It vaguely resembles TT2 - at least in the way you put the variables. This let me take a bunch of TT2 templates and more or less keep them switching to the new templating system. The other thing I love is that all what's more complicated than a simple variable is just plain Perl - and I love Perl.

Why, then? I'm working on an automatic deployment system, to build up a server image that can be deployed and auto-configures all those tiny bits like network configurations and stuff like this, based on some master configuration file. At first I developed it in TT2, and executed it on my machine, but then each new server needed my intervention after server image deploy. This should let me avoid this.

So, I needed something that I could carry very easily anywhere Perl 5.8 was present.

One thing that makes me proud is that for the new 1.1 release there are a few features added and a few removed. Like accessors for the three member variables: actually not needed due to the extreme simplicity of the module. I'm still thinking if an "include" feature is needed, but I won't probably be adding it until it's evident that this is a lacking feature. It's like a gym where I can practice some refrain to feeping creaturism - ehr, creeping featurism.


you lost me

perrin on 2008-04-08T16:55:42

You developed this because you didn't want to install TT2? That doesn't make any sense.

Re:you lost me

sigzero on 2008-04-09T01:32:50

Isn't writing your own template system a Perl rite of passage? :-)

Re:you lost me

perrin on 2008-04-09T01:50:55

Yes! Everyone should write a templating system. Most people should not release it on CPAN though.

Re:you lost me

Aristotle on 2008-04-09T02:20:53

I’m the other way around. I haven’t, but I plan to release it.

Re:you lost me

polettix on 2008-04-09T07:34:17

This is where you lost me, actually. I think I'm not invading anyone's space (I've taken a single and quite specific namespace), I find this module quite useful for myself to share it with others that might have my same need, and I put it into a place where you can go, rate it with one star and comment at will to discourage others from using it. I'd also like to understand what makes any of us stay inside or outside the "most people" set who should refrain from posting stuff like this in CPAN... If it's bad code, poorly commented, or weak in what it claims to do I'm eager to accept suggestions; apart from this, it only seems 1337 nonsense.

Re:you lost me

Aristotle on 2008-04-09T10:20:45

It does make force people to sift through ever more similar modules. When you’re a novice with no idea what modules are “community standard,” or even if you’re a community veteran looking at an area without an established default choice, that can be a daunting task. How does one evaluate all those modules? How does one compare candidates?

Re:you lost me

perrin on 2008-04-09T13:16:44

It's nothing personal. It's just that when someone goes to CPAN looking for a template module and searches for "template", they will find a crazy number of modules, and every new module makes it harder for a newbie to find the right one.

Which ones should be released? Ideally, the ones that have long-term viability. The field is so crowded that in order to compete you need great documentation, a full test suite, a mailing list, and a commitment to support the module for years to come.

You also need to offer something different, and this is where I would criticize your module. It looks to me from a brief glance at your documentation that everything your module does can be done with TT2 using the in-line perl capabilities it offers.

Re:you lost me

polettix on 2008-04-11T20:16:57

The difference my module tries to offer is having a single file module that can be included into a script easily - something along the line of the ::Tiny modules (but I don't want to start a discussion about this, I promise :) It does what it claims in not-so-many lines of code, which is good for the application I'm writing. I felt the need for something this simple and short, and I didn't find anything.

I see the point in not confusing "customers", anyway. Do you happen to have an updated version of the templating systems comparison you wrote in perl.com/mod_perl? Is it safe to use http://perl.apache.org/docs/tutorials/tmpl/comparison/comparison.html ? I'm putting a section "SHOULD YOU USE THIS?" somewhere at the beginning of the documentation, and it seems reasonable to point people there to have a complete discussion on the topic.

Re:you lost me

perrin on 2008-04-11T20:23:06

That's the most up-to-date version of the article. I updated it last month. Thanks for the link.

Re:you lost me

polettix on 2008-04-09T07:24:47

I thought that saying "I needed something that I could carry very easily anywhere Perl 5.8 was present" would make the point clear. The module can be embedded within a script (that's the "easily" part) without needing anything more than the script itself and Perl 5.8.

I'm not supposed to mess with the Perl installation on the server, and I definitively remember that installing TT2 involved carrying a lot of other stuff as well. I admit my lazyness in not checking if any of these modules are XS or not :)

Re:you lost me

Aristotle on 2008-04-09T10:12:43

They have XS parts, but if memory serves, the XS is all optional. The XS part of Template Toolkit itself definitely is.

Re:you lost me

perrin on 2008-04-09T13:17:55

You should be able to just copy the lib files from the TT2 distribution and use them. Any pure perl module can be bundled into your own code.