Re: [SMARTY] Re: [SMARTY-DEV] Re: [SMARTY] modifier_string_format in 2.5.0-RC1
| From: | messju mohr | Date: | Thu, 06 Mar 2003 22:44:32 +0000 |
| Subject: | Re: [SMARTY] Re: [SMARTY-DEV] Re: [SMARTY] modifier_string_format in 2.5.0-RC1 | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-912@lists.php.net to get a copy of this message | ||
On Thu, Mar 06, 2003 at 04:20:50PM -0600, Monte Ohrt wrote:
> func_get_args() would work well for modifiers with variable number of
> parameters. But that breaks all existing modifiers because right now
> they look like:
>
> smarty_modifier_foo($string, $foo, $bar, ...) {}
>
> and would need to be changed to:
>
> smarty_modifier_foo($string, $params) {
> $foo = $params[0];
> $bar = $params[1];
> ...
> }
sorry, i don't understand you here.
i wanted to say, that one can use func_get_args() to write modifiers
with variable arguments. it works without having to touch anything
inside smarty. that means all modifiers work as usual, but if one
feels the need for a variable number of args, he does:
function smarty_modifier_foo() {
$params = func_get_args();
$string = array_shift($params);
...
}
i didn't test that, but it should be equivalent, to your example above.
> Since we couldn't even do something like func_get_args() when Smarty was
> first designed, that probably has an influence on why string_format
> works the way it does.
i don't think you have to excuse for that. :)
> Monte
>
>
> On Thu, 2003-03-06 at 16:12, Paul Lockaby wrote:
> > messju mohr wrote:
> > > On Thu, Mar 06, 2003 at 03:55:47PM -0600, Monte Ohrt wrote:
> > >
> > >>Hmm, I'm not the originating author of the modifier structure, but I'll
> > >>take a guess :-) Function attributes have name/value pairs so an
> > >>associative array makes sense, and order is not an issue. OTOH, modifier
> > >>parameters are only values so their order is important. I suppose they
> > >>could have been passed as an enumerated array of values, that way the
> > >>second parameter can be the smarty object much the same as functions
> > >>are. But then your modifier would need to know what each value of
> > >>$params[0], $params[1], etc. are for without an intuitive name.
> > >
> > >
> > > one can use func_get_args() to write modifiers with a variable number
> > > arguments, so there is no need to break bc for this.
> > >
> >
> > Hmm, didn't realize that. Excuse me for a moment for being dumb.
> >
> > > but having &$smarty available in modifiers would be worth it for me... :)
> > >
> >
> > ~Paul
> --
> Monte Ohrt <monte@ispi.net>
--
Torx-Schrauben: Hände-Weg-Schrauben
nach Marc Habers Kollegen