Sigma template
| From: | Sergey Vasilyev | Date: | Thu, 20 May 2004 01:38:20 +0000 |
| Subject: | Sigma template | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-12642@lists.php.net to get a copy of this message | ||
Hello,
I have two questions about HTML_TEMPLATE_SIGMA:
1. Function callbacks are performed every time each block is parsed. This
includes "empty" blocks. I don't think this is the way it should be. For
example, consider the following template:
<table>
<!-- BEGIN table_cell -->
func_startCell({col_num}){table_item}func_endCell({col_num})
<!-- END table_cell -->
func_endRow({col_num})
</table>
Functions func_startCell and func_endCell keep track of all calls and
return the tags for opening/closing <tr>'s and <td>'s depending on the
number of columns {col_num}. Function func_endRow should close the <tr>
tag if needed.
Now if we try to parse this, we will run into a small problem:
func_endRow won't work as expected. The reason for this is that when the
global block gets parsed it will again execute func_startCell and func_endCell
from the inner table_cell block (even though this block will be
considered empty) before it executes func_endRow.
2. If there are two identical calls to the same function with the same
parameters within the same block, the result from the first call is
saved and used for the second call. This might seem like a good idea,
however these two calls might return different results - for example,
toggling the colors of table rows. There is an easy way to bypass this -
just introduce a dummy parameter to make these calls look different.
However this is a little cumbersome. It would be much better to be able
to either turn on/off this behavior, or maybe instead be able to save
results from function calls into local variables for later use, e.g.
...{aaa='blah-blah-blah':function}.....{aaa}
This doesn't look like it is very difficult to implement.
Thanks,
Sergey Vasilyev