if you can install one module, why can't you install 20?

Simply due to convenience and cleanliness. Imagine what a cgi-bin looks like after you install four of five scripts which all require their own set of 30 external files. Even if the extra files go into subdirectories, it looks a lot better, but it doesn't look good. I'd really like to telnet in and do 'su -c perl -MCPAN (..)', believe me. :-/ But I do not have that convenience in this case, and even if I did, others might not, in case I release the script. Requiring a specific multilevel directory tree to place the modules in is going to make installation for less adept users painful also. So the fewer extra files I can get away with, the better. HTML::Template is perfect in that regard, a single file that I can rename and then manually require/import if need be.

But no one is twisting your arm and telling you to use the full syntax of TT! Just use the part you want.

I would - but again, see above paragraph.

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 am aware of that trap and am not going to fall for it. I want the interpolation to provide enough flexibility to implement these features on the template's end (rather than the templating module's) without the template language providing elaborate control constructs and that should be doable with a fancy variable dereferencing syntax.

The closest to what you are suggesting is Text::Template, but I don't know how easy it would be to extend.

I will have a look.

So far I fetched HTML::Template and found that getting it to comply to my wishes is very possible by just wrapping a layer of own routines around it. Basically I lie to the module about my data and feed it through the back door; the main dirty trick is that I use the association mechanism to make it think that [foo.bar] is an actual variable while my param() silently derefences that into $t->{foo}->{bar}. Anything but conceptually clean - but it works well.

Edit: I had a look at Text::Template - that doesn't at all seem to be like what I want. It uses Perl embedded into templates, whereas I want an absolutely minimalistic minilanguage. Am I missing something?


In reply to Re^4: I am about to write my very own templating module.. by Aristotle
in thread I am about to write my very own templating module.. by Aristotle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.