cvs: smarty / NEWS Smarty_Compiler.class.php

From: Date: Thu, 11 Apr 2002 16:22:51 +0000
Subject: cvs: smarty / NEWS Smarty_Compiler.class.php
Groups: php.smarty.cvs 
Request: Send a blank email to php-smarty-cvs+get-41@lists.php.net to get a copy of this message
andrei Thu Apr 11 12:22:51 2002 EDT Modified files: /smarty NEWS Smarty_Compiler.class.php Log: Added ability to use simple variables for array indices or object properties. Index: smarty/NEWS diff -u smarty/NEWS:1.185 smarty/NEWS:1.186 --- smarty/NEWS:1.185 Fri Apr 5 12:16:49 2002 +++ smarty/NEWS Thu Apr 11 12:22:50 2002 @@ -1,3 +1,5 @@ + - added ability to use simple variables as array indices or + object properties. (Andrei) - added ability to unregister pre/postfilters plugins at runtime. (Andrei) - added 'htmlall' attribute to escape modifier. (Monte) Index: smarty/Smarty_Compiler.class.php diff -u smarty/Smarty_Compiler.class.php:1.108 smarty/Smarty_Compiler.class.php:1.109 --- smarty/Smarty_Compiler.class.php:1.108 Fri Apr 5 12:16:52 2002 +++ smarty/Smarty_Compiler.class.php Thu Apr 11 12:22:50 2002 @@ -239,7 +239,7 @@ /* If the tag name matches a variable or section property definition, we simply process it. */ - if (preg_match('!^\$\w+(?>(\[(\d+|\w+(\.\w+)?)\])|((\.|->)\w+))*(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|]+))*)*$!', $tag_command) || // if a variable + if (preg_match('!^\$\w+(?>(\[(\d+|\w+(\.\w+)?)\])|((\.|->)\$?\w+))*(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|]+))*)*$!', $tag_command) || // if a variable preg_match('!^#(\w+)#(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|]+))*)*$!', $tag_command) || // or a configuration variable preg_match('!^%\w+\.\w+%(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|]+))*)*$!', $tag_command)) { // or a section property settype($tag_command, 'array'); @@ -1085,7 +1085,7 @@ { $qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\''; - $var_exprs = preg_grep('!^\$\w+(?>(\[(\d+|\w+(\.\w+)?)\])|((\.|->)\w+))*(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|]+))*)*$!', $tokens); + $var_exprs = preg_grep('!^\$\w+(?>(\[(\d+|\w+(\.\w+)?)\])|((\.|->)\$?\w+))*(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|]+))*)*$!', $tokens); $conf_var_exprs = preg_grep('!^#(\w+)#(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|]+))*)*$!', $tokens); $sect_prop_exprs = preg_grep('!^%\w+\.\w+%(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|]+))*)*$!', $tokens); @@ -1119,7 +1119,7 @@ $var_ref = $parts[0]; $modifiers = isset($parts[1]) ? $parts[1] : ''; - preg_match_all('!\[\w+(\.\w+)?\]|(->|\.)\w+|^\w+!', $var_ref, $match); + preg_match_all('!\[\w+(\.\w+)?\]|(->|\.)\$?\w+|^\w+!', $var_ref, $match); $indexes = $match[0]; $var_name = array_shift($indexes); @@ -1152,7 +1152,10 @@ $output .= "[\$this->_sections['$section']['$section_prop']]"; } } else if ($index{0} == '.') { - $output .= "['" . substr($index, 1) . "']"; + if ($index{1} == '$') + $output .= "[\$this->_tpl_vars['" . substr($index, 2) . "']]"; + else + $output .= "['" . substr($index, 1) . "']"; } else { $output .= $index; }

« previous php.smarty.cvs (#41) next »