[PHPTAL] Chained expressions on tal:condition

Iván -DrSlump- Montes drslump at pollinimini.net
Fri Feb 1 01:11:54 CET 2008


Hello list,

I've modified the tal:condition attribute to handle chained
expressions so it can do stuff like "cart/items | nothing" or even
"showItems | cart/items | nothing".

I'm attaching the whole modified file since the almost all lines have changed.

I've also noticed that phptal_isempty() returns true only for Null,
False and zero length strings. However I feel that it should also
check for empty arrays. I do agree though that a int/float of value 0
should not be considered empty.
I propose the following patch to implement the empty array check.

Index: Context.php
===================================================================
--- Context.php	(revision 331)
+++ Context.php	(working copy)
@@ -374,7 +374,7 @@

 function phptal_isempty($var)
 {
-	return $var === null || $var === false || $var === '';
+	return $var === null || $var === false || $var === '' || (
is_array($var) && count($var)===0 );
 }

 function phptal_escape($var, $ent, $encoding)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Condition.php
Type: application/octet-stream
Size: 3125 bytes
Desc: not available
Url : http://lists.motion-twin.com/pipermail/phptal/attachments/20080201/a492620a/Condition.obj


More information about the PHPTAL mailing list