On Thu, Oct 30, 2008 at 9:43 AM, Michael Wichmann <[EMAIL PROTECTED]>wrote:
> | Mihai Bazon wrote:
> |
> | I for one don't quite understand why/how you want to use this, but
> | probably a simple way is to use a variable:[% SET condition =
> | something | eval; IF condition %] ... [% END %]
> | Could you better explain your intentions...?
> | -M.
>
> Hi Mihai,
>
> let me explain my intention:
>
> There is some data from a database which has to be shown in a table.
> But I want to split the information into two tables without querying the
> database again.
> So I do need table filters to prevent writing the same code twice.
>
> My idea is:
>
> - the Table structure with headers and rows becomes a block.
> - the part that renders the rows depends on a filter expression
> - I can call the block with PROCESS and a filtering criteria which has to
> be evaluated
>
> -> like this [% PROCESS table filter="user.isLoggedIn"%]
> -> or that [% PROCESS table filter="NOT user.isLoggedIn" %]
>
Why not just do the filtering on the Perl side, before processing the
template?
my %template_vars = (
logged_in => [ grep { $_->{isLoggedIn} } @rows ],
not_logged_in => [ grep { !$_->{isLoggedIn} } @rows ],
...
);
Then you can just call the table-producing block twice, once with logged_in
and once with not_logged_in.
--Sean
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates