Re: [SMARTY-DEV] another way to handle objects]

From: Date: Thu, 26 Dec 2002 18:18:28 +0000
Subject: Re: [SMARTY-DEV] another way to handle objects]
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-491@lists.php.net to get a copy of this message
Should it support object access other than directly assigned? Maybe it only support this, and the app needs to be designed in such a way that the object assignment works the way Smarty expects. If you really need something more elaborate, write your own plugin. Monte On Tue, 2002-12-24 at 16:57, M Mohr wrote: > Hello, > > On Tue, Dec 24, 2002 at 09:41:00AM -0600, Monte Ohrt wrote: > > 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? > > I also had this idea some time ago :) > > > example: > > > > {object name="myobj" method="get_headline" p1=$foo > > p2=$smarty.const._MY_CONST} > > I see a problem here. this works fine with objects that are simply > assigned (by ref maybe) as template variables. But if your object is > an array element, or itself an object property we have something like: > {object name="myobj->children.0" p1=$foo... > > This would be hard to be parsed at runtime, wouldn't it? And we > cannot parse it at compile-time using the old function-call-parsing > and -handling. > > Just my thoughts. > > > 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>

« previous php.smarty.dev (#491) next »