another way to handle objects
| From: | Monte Ohrt | Date: | Tue, 24 Dec 2002 15:41:00 +0000 |
| Subject: | another way to handle objects | ||
| Groups: | php.smarty.dev | ||
| Request: | Send a blank email to php-smarty-dev+get-487@lists.php.net to get a copy of this message | ||
This had to have been thought of already, so I'll throw it out there
(again?) and see what reaction we get...
Currently, we are looking at supporting this kind of syntax for objects:
{$myobj->get_headline($foo,$smarty.const._MY_CONST)}
Instead of supporting a new syntax, why not use the exisiting template
syntax and access them through a template function?
example:
{object name="myobj" method="get_headline" p1=$foo
p2=$smarty.const._MY_CONST}
This way we aren't polluting Smarty with new syntax support, we don't
have to make special parsing logic for the parameters, and we are only
adding a plugin. The only downside I see is that the syntax is a little
wordier to work with, but it works all the same. I'm not sure of the
best way to handle parameters since you have to name them. I just used
p1, p2, etc. There are probably other ways to simplify the syntax, maybe
something like:
{object name="myobj->get_headline" parameters="\$foo, \$bar,
\$smarty.const._MY_CONST"}
The CVS version of Smarty supports applying modifiers to function output
so you can do this:
{object|upper name="myobj" ...}
Thoughts?
Monte
--
Monte Ohrt <monte@ispi.net>