Re: [SMARTY-DEV] RE: parser syntax change
| From: | Andr� Rabold | Date: | Thu, 19 Dec 2002 08:40:56 +0000 |
| Subject: | Re: [SMARTY-DEV] RE: parser syntax change | ||
| References: | 1 2 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-453@lists.php.net to get a copy of this message | ||
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>
>