[Templates] tt annoyances

Mark Mills mark@xodiax.com
Fri, 10 Oct 2003 01:01:00 -0400


Mark D. Anderson wrote:
> 2. There is no "typeof" or "instanceof" operator (or similar).
> Perl has "ref" and "isa"; practically all real programming languages
> have at least one of those operators.

I'd bet a whole shiny quarter that people on this list can name more 
languages that don't than you can that do. :)

> 7. There is no way to comment out a whole block of template lines which 
> includes
> other directives. That is, you can't nest things like [%# [% %] %].
> I end up having to create a separate emacs buffer to just hold fragments.
> In perl this can be done with tricks like "=for IGNORE".

Simple trick for that one:

[% TAGS <+ +> %]<+#
Stuff with [% variables %] in it
+><+ TAGS [% %] +>

> 8. A bug: [% SET str = 'a'; str.repeat(0) %] prints 'a', not ''

I think is is deliberate.
[% str.repeat("") %] also prints 'a'.
[% str.repeat('0 but true') %] prints ''.

Still, we should probably fix that in Stash.pm... maybe...
     'repeat'  => sub {
         my ($str, $count) = @_;
         $str = '' unless defined $str;
!        $count ||= 1;
+        $count ||= "0 but true";
         return $str x $count;
     },


> 9. The diagnostics stink. (This was a topic of an earlier email post.)

Hoo boy. Yeah. :) Luckily, since most of us don't use it as a full OOP 
language and just use it to pretty print data we developed in perl 
proper, most of the errors are easy to find.

--mark mills
Xodiax Engineering