in reply to Template newbie question. Is it lack of understanding or lack of DWIM

Template Toolkit doesn't support ucfirst as a method, but it does have a ucfirst filter. I don't think it supports the ternary operator, either. You could write it like this:

[% IF section %][% section | ucfirst %] - [% END %]

Replies are listed 'Best First'.
Re^2: Template newbie question. Is it lack of understanding or lack of DWIM
by Trizor (Pilgrim) on Apr 16, 2007 at 18:56 UTC
    It does support the ternary operator, when I run that with section undef it produces nothing. Well I suppose I should finish reading aforementioned documentation instead of stopping after GET and SET. The filter solution feels somewhat less elegant though.
Re^2: Template newbie question. Is it lack of understanding or lack of DWIM
by Rhandom (Curate) on Apr 16, 2007 at 20:47 UTC
    You can make it a little less visually dense by changing it to something like the following (works in TT2 and CET):

    [% IF section ; section|ucfirst ; ' - ' ; END %]


    my @a=qw(random brilliant braindead); print $a[rand(@a)];