Re: [SMARTY] Class::method() in if tags

From: Date: Mon, 08 Mar 2004 21:19:57 +0000
Subject: Re: [SMARTY] Class::method() in if tags
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11077@lists.php.net to get a copy of this message
On Mon, Mar 08, 2004 at 04:22:34PM +0100, Jochem Maas wrote: > David Förster wrote: > > >Hello, > > > >{if Auth::logged_in()} > >produces > >Fatal error: Smarty: [in main.tpl line 115]: syntax error: unidentified > >token '::logged_in()' > > > >Can I use a different syntax or are there any plans to support that in the > >future? this would enable static method-calls inside if-functions: Index: Smarty_Compiler.class.php =================================================================== RCS file: /repository/smarty/libs/Smarty_Compiler.class.php,v retrieving revision 1.315 diff -u -r1.315 Smarty_Compiler.class.php --- Smarty_Compiler.class.php 23 Feb 2004 23:14:40 -0000 1.315 +++ Smarty_Compiler.class.php 8 Mar 2004 21:16:49 -0000 @@ -163,7 +163,7 @@ // matches valid function name: // foo123 // _foo_bar - $this->_func_regexp = '[a-zA-Z_]\w*'; + $this->_func_regexp = '(?:[a-zA-Z0-9_]+\:\:)?[a-zA-Z_]\w*'; // matches valid registered object: // foo->bar @@ -1218,6 +1218,7 @@ /* Tokenize args for 'if' tag. */ preg_match_all('/(?> ' . $this->_obj_call_regexp . '(?:' . $this->_mod_regexp . '*)? | # valid object call + ' . $this->_func_regexp . ' | # valid function name ' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*)? | # var or quoted string \-?0[xX][0-9a-fA-F]+|\-?\d+(?:\.\d+)?|\.\d+|!==|===|==|!=|<>|<<|>>|<=|>=|\&\&|\|\||\(|\)|,|\!|\^|=|\&|\~|<|>|\||\%|\+|\-|\/|\*|\@ | # valid non-word token \b\w+\b | # valid word token is that of broader use? greetings messju > Hi, > > I posted a related question about that I would like to use dereferenced > syntax (PHP5) e.g. > > {$Field->getValue()->getName()} > > does anyone have any pointers (maybe tips onchanging the rather long > regexps that are used to parse the templates*), maybe one of the smarty > developers has some insight regarding possible future support of the > dereferenced/static object syntax? > > *I haven't had much success in trying to change the 1000+ char regexp > that is used to indentify/parse PHP 'object'-related expressions. > > rgds, > > Jochem > > ps - sorry for reposting but I am really in need of a pointer or to know > whether there is any intention to support the above mentioned. I had the > idea that maybe my last post was not well understood (or it just > silently fell off the radar, so to speak... these things happen ;-) > > pps - just out of interest, do the regexps used to parse the templates > really need to be so long? my first impression was 'its got to be > possible to do that more consisely' - I atleast assumed that Smarty has > a potential performance gain to be had by optimizing these regexps. I > was quite amazed by the size! > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.smarty.general (#11077) next »