{$object->method("param")} constructs

From: Date: Mon, 02 Dec 2002 10:40:37 +0000
Subject: {$object->method("param")} constructs
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-355@lists.php.net to get a copy of this message
I have modified the Smarty_Compiler class a bit and now the following syntax is also supported by Smarty: <-- snip --> {$myObject->myMethod("param1", "param2")} <-- snip --> and even <-- snip --> {assign var="param1" value="abcdef"} {assign var="param2" value="123456"} {$myObject->myMethod($param1, $param2)} <-- snip --> works great :-) I'm not sure if it affects other functionality of Smarty but it works great for me and I'm using complex templates. The only thing I found not working are modifiers on these functions. You cannot do something like this: {$myObject->myMethod($param1)|myModifier} Modifiers on "normal" variables still work as expected. All you need is to change line 283 of Smarty_Compiler.php to this: <-- snip --> if (preg_match('!^\$\w+(?>(\[(\d+|\$\w+|\w+(\.\w+)?)\])|((\.|->)\$?\w+))*(\((.* ?)\))?(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|]+))*)*$!', $tag_command) || // if a variable <-- snip --> I have added the "(\((.*?)\))?" in the middle of the preg string which allows to call class methods with parameters. Monte, what do you think? Should this be a standard functionality for Smarty? Cheers, André

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