Re: [SMARTY] modifier_string_format in 2.5.0-RC1
| From: | Paul Lockaby | Date: | Thu, 06 Mar 2003 21:42:46 +0000 |
| Subject: | Re: [SMARTY] modifier_string_format in 2.5.0-RC1 | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Groups: | php.smarty.dev php.smarty.general |
| Request: | Send a blank email to php-smarty-dev+get-898@lists.php.net to get a copy of this message | ||
Monte Ohrt wrote:
I see what is wrong. Look at the examples in the manual. Here is how string_format works: {$number|string_format:"%.2f"} Notice the formatting is in the parameter, not in the variable. You are trying to do this: {"test %s"|string_format:"hello"} when it actually works like this: {"hello"|string_format:"test %s"} I agree the implementation isn't too flexible because you can't give it more than one value to format. It should probably work the other way around like this: {"%s foo %s foo %s"|string_format:$val1:$val2:$val3} But that breaks backward compatability. Thoughts? MonteOk, I see the difference and how it works now, though I can't say that it is the most intuitive implementation. Usually the modifier modifies the string it is attached to, not the other way around. For people like myself who want it the other way, and for the sake of backwards compatibility, one can simply register the modifier in the code as I have done. As an idea for being able to attach what is basically a dynamic amount of arguments to a modifier, why don't you make modifiers work the way function plugins do: pass a $params variable that is an array of all the arguments? That seems to be somewhat logical and at the same time backwards compatible with existing templates, even though all modifier plugins will have to be rewritten. ~Paul