Rick Delaney | 3 Mar 2007 00:51
Picon

Re: for ... else

On Mar 02 2007, Luke Palmer wrote:
> Or I wonder if there's really a problem here that we're
> addressing, or whether we're just adding syntax because we can.

This syntax awkwardness comes up a lot in various kinds of reports.

    for  <at> records {
        .print;
    }
    if  <at> records {
        say "Search returned no records";
    }

I've always found it annoying that I have to write  <at> records (or
whatever) twice.  I don't know if Thomas's idea is the best possible but
it's not horrible.  Hmm, I wonder if I could get it into Template
toolkit.

    [% FOREACH records %]
        <span>[% whatever %]</span>
    [% ELSE %]
        <span>Search returned no records.</span>
    [% END %]

--

-- 
Rick Delaney
rick <at> bort.ca


Gmane