Support for NULL in Smarty?!
| From: | Andr� Rabold | Date: | Wed, 19 Feb 2003 14:42:44 +0000 |
| Subject: | Support for NULL in Smarty?! | ||
| Groups: | php.smarty.dev | ||
| Request: | Send a blank email to php-smarty-dev+get-732@lists.php.net to get a copy of this message | ||
It was already discussed some time ago ... but I cannot find the thread
anymore and I cannot remember if a decission was made.
I cannot use NULL as a function parameter in Smarty. But it would be very
usefull for me to explicitly set some vars to NULL. For example if a
function has set a parameter to a default value other that "" or NULL.
One other thing I discovered is the behaviour of TRUE and FALSE within a
template. Both get compiled as 1 or 0 not as true / false. It's nearly the
same but not exacly.
So I have created patch which "fixed" the TRUE/FALSE and adds support for
NULL:
Index: Smarty_Compiler.class.php
===================================================================
RCS file: /repository/smarty/Smarty_Compiler.class.php,v
retrieving revision 1.177
diff -r1.177 Smarty_Compiler.class.php
56c56
< var $_permitted_tokens =
array('true','false','yes','no','on','off');
---
> var $_permitted_tokens =
array('true','false','yes','no','on','off','null');
664a665,666
> if (is_null($arg_value))
> $arg_value = 'null';
1345c1347
< $token = true;
---
> $token = 'true';
1347c1349,1351
< $token = false;
---
> $token = 'false';
> } else if ($token == 'null') {
> $token = 'null';
Good or bad?
André