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 ]

polettix (7564)

  (email not shown publicly)

Journal of polettix (7564)

Monday April 07, 2008
07:23 PM

Falled into the trap: Template::Perlish

[ #36096 ]

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.

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.
  • You developed this because you didn't want to install TT2? That doesn't make any sense.
    • Isn't writing your own template system a Perl rite of passage? :-)
      • Yes! Everyone should write a templating system. Most people should not release it on CPAN though.
        • I’m the other way around. I haven’t, but I plan to release it.

        • 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
          • 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?

          • 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

            • 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 t

              • That's the most up-to-date version of the article. I updated it last month. Thanks for the link.
    • 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 :)
      • They have XS parts, but if memory serves, the XS is all optional. The XS part of Template Toolkit itself definitely is.

      • 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.