UPDATE !!! Re: [SMARTY-DEV] RE: parser syntax change

From: Date: Thu, 19 Dec 2002 10:38:28 +0000
Subject: UPDATE !!! Re: [SMARTY-DEV] RE: parser syntax change
References: 1 2 3  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-454@lists.php.net to get a copy of this message
In my last posting was still a little error {$foo->$bar[$blah]}and {$foo["blah"]->$bar} doesn't work as expected. This should be possible in my opinion! So I replaced the $this->_obj_regexp assignment line(s) in the Smarty_Compiler constructor with the following: // matches non-dollar vars of objects: (used in $_obj_regexp) // foo // foo.bar // foo.$bar // foo.bar.foobar // foo[0] // foo[$bar] // foo[5][blah] // foo[5].bar[$foobar][4] // foo[5].$bar $this->_ovar_regexp = '\w+(?:\[\$?\w+(?:\.\w+)*\])*(?:\.\$?\w+(?:\[\$?\w+(?:\.\w+)*\])*)*'; // matches valid object call: // $foo->bar // $foo->bar() // $foo->bar("text") // $foo->bar($foo, $bar, "text") // $foo->bar($foo|bar, "foo"|bar) // $foo->bar->blah() $this->_obj_regexp = '(?:' . $this->_dvar_regexp . '\->(?:' . $this->_ovar_regexp . '\->)*(?:' . $this->_ovar_regexp . '|' . '\w+\((?:(?:\w+|' . $this->_var_regexp . $this->_mod_regexp . ')(?:\s*,\s*(?:\w+|' . $this->_var_regexp . $this->_mod_regexp .'))*)*\)?))'; André "André Rabold" <arabold@nero.com> schrieb im Newsbeitrag news:20021219084057.57671.qmail@pb1.pair.com... > Hi folks, > > I found some bugs in the latest CVS version: > > - {$sectionvar[record.index_prev]} doesn't work anymore > - {$foo.$bar} doesn't work anymore > - {$foo->bar->blah()} doesn't work (cascaded objects wouldn't be too bad) > ;-) > > > So I checked the Smarty_Compiler and *tatatataaaaa* here are some > fixes! But here is a small question: Is {$foo[bar.blah.blub]} possible and > does this make sense? Because of the {$sectionvar[record.index_prev]} fix > I implemented this works now too - good or bad? > Cascading objects {$foo->bar->blah->blub()} should be possible or not? I > use it because I have a single global object containing all others (i.e. > $nextgen->user, $nextgen->module, $nextgen->settings etc.). So there are > no naming conflicts with regular template variables. Thoughts? > > André > > > > cvs diff Smarty_Compiler.class.php (in directory C:\CVS-Checkout\smarty\) > Index: Smarty_Compiler.class.php > =================================================================== > RCS file: /repository/smarty/Smarty_Compiler.class.php,v > retrieving revision 1.136 > diff -r1.136 Smarty_Compiler.class.php > 99a100 > > // $foo.$bar > 104a106 > > // $foo[5].$bar > 106c108 > < $this->_dvar_regexp = '\$\w+(?:\[\$?\w+\])*(?:\.\w+(?:\[\$?\w+\])*)*'; > --- > > $this->_dvar_regexp = > '\$\w+(?:\[\$?\w+(?:\.\w+)*\])*(?:\.\$?\w+(?:\[\$?\w+(?:\.\w+)*\])*)*'; > 145c147,148 > < $this->_obj_regexp = '(?:\$\w+(?:\.\w+)*\->\w+(?:\((?:(?:\w+|' . > $this->_var_regexp . $this->_mod_regexp > --- > > // $foo->bar->blah() > > $this->_obj_regexp = > '(?:\$\w+(?:\[\$?\w+(?:\.\w+)*\])*(?:\.\w+)*(?:\->\w+(?:\[\$?\w+(?:\.\w+)*\] > )*(?:\.\w+)*)*\->\w+(?:\((?:(?:\w+|' . $this->_var_regexp . > $this->_mod_regexp > 1260c1263 > < > preg_match_all('!(^\w+)|(?:\[\$?\w+\])|\.\w+|->\w+(?:\([^\)]*\))?!', > $var_ref, $match); > --- > > > preg_match_all('!(^\w+)|(?:\[\$?\w+(?:\.\w+)*\])|\.\$?\w+|->\w+(?:\([^\)]*\) > )?!', $var_ref, $match); > > > > > > "Monte Ohrt" <monte@ispi.net> schrieb im Newsbeitrag > news:1040257085.11946.201.camel@lena.ispi.prv... > > No... currently the assigned template variables are extracted into PHP > > name space upon a fetch() or display(). This was done basically so the > > embedded variables in function params would work: > > > > {myfunc file="$foo/$bar.tpl"} > > > > Now we handle this differently, and no extraction is required. The > > variables are assigned to the template in thier own namespace, and they > > are referenced as such. > > > > Monte > > > > On Wed, 2002-12-18 at 16:58, Gerard wrote: > > > > Since the removal of exporting assigned variables. > > > > > > What exactly was that? PHP globals or something? > > > > > > Gerard > > -- > > Monte Ohrt <monte@ispi.net> > > > >

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