[Petal] Re: Petal wish list

William McKee william@knowmad.com
Thu, 25 Jul 2002 08:45:46 -0400


I just wanted to forward this message to the list to add the excellent ideas into 
the archive.

William

------- Forwarded message follows -------
Date sent:      	Thu, 25 Jul 2002 11:37:33 +0100
From:           	Jean-Michel Hiver <jhiver@mkdoc.com>
To:             	William McKee <william@knowmad.com>
Subject:        	Re: Petal wish list

Hi,

> Jean-Michel,
> 
> If you're keeping a wish list around for Petal, could you add the ability
> to do simple expression evaluation inside of TAL tags? For example, it'd
> be nice to be able to do something if a condition is not met: 	<option
> value="" petal:if="!user_id" >Select</option>

Well, if I did that I would be crossing the yellow line of separating
content and code I think. For the example above you could use :not or
:false modifiers, i.e.

  <option value="" petal:if=":false user_id" >Select</option>

You can (and you are encouraged to!) write your own Petal modifiers, see
the documentation for Petal::Hash for details on how to do it. You'll see
it's pretty easy to do :-)

Another way of doing it is to give Petal a dummy object which has method
that do what you want, i.e. you could have an 'operations' object that
could look like that:

package Operation;
use strict;
use warnings;

sub lt { return shift() < shift() }
sub gt { return shift() > shift() }

etc...


Then you'd do:

  return $template->process ( operation => $operation, day => 5 );

<p petal:condition="operation.lt $day 15">
  Today is before the 15th
</p>
<p petal:condition="operation.ge $day 15">
  Today is the 15th or after the 15th
</p>


But I'd go for the custom modifier :-)
perldoc Petal::Hash !

Cheers,
-- 
IT'S TIME FOR A DIFFERENT KIND OF WEB
===========================================================
=====
  Jean-Michel Hiver - Software Director
  jhiver@mkdoc.com
  +44 (0)114 255 8097
===========================================================
=====
                                     VISIT HTTP://WWW.MKDOC.COM

------- End of forwarded message -------
-- 
 Lead Developer
 Knowmad Services Inc. || Internet Applications & Database Integration
 http://www.knowmad.com