cvs: smarty / NEWS /libs Smarty_Compiler.class.php

"Messju Mohr" <[email protected]>
Newsgroups gmane.comp.php.cvs.smarty
Message-ID <cvsmessju1063700158@cvsserver>
messju		Tue Sep 16 04:15:58 2003 EDT

  Modified files:              
    /smarty	NEWS 
    /smarty/libs	Smarty_Compiler.class.php 
  Log:
  apply modifiers only once to section-loop and foreach-from attributes
  
  
  
Index: smarty/NEWS
diff -u smarty/NEWS:1.395 smarty/NEWS:1.396
--- smarty/NEWS:1.395	Fri Sep 12 09:40:52 2003
+++ smarty/NEWS	Tue Sep 16 04:15:57 2003
@@ -1,3 +1,5 @@
+  - apply modifiers only once to section-loop and foreach-from attrs (messju)
+  - remove use of _smarty_cached_paths-files (messju)
   - remove Smarty::_plugin_implementation_exists() - use is_callable() (messju)
   - ignore {strip}/{/strip) inside {strip}-blocks (messju)
   - fixed removal of leading/trailing newlines in {strip}-blocks (messju)
Index: smarty/libs/Smarty_Compiler.class.php
diff -u smarty/libs/Smarty_Compiler.class.php:1.284 smarty/libs/Smarty_Compiler.class.php:1.285
--- smarty/libs/Smarty_Compiler.class.php:1.284	Mon Sep 15 10:30:56 2003
+++ smarty/libs/Smarty_Compiler.class.php	Tue Sep 16 04:15:58 2003
@@ -39,7 +39,7 @@
  * @package Smarty
  */
 
-/* $Id: Smarty_Compiler.class.php,v 1.284 2003/09/15 14:30:56 messju Exp $ */
+/* $Id: Smarty_Compiler.class.php,v 1.285 2003/09/16 08:15:58 messju Exp $ */
 
 /**
  * Template compiling class
@@ -496,13 +496,13 @@
 
             case 'foreachelse':
                 $this->_foreachelse_stack[count($this->_foreachelse_stack)-1] = true;
-                return "<?php endforeach; else: ?>";
+                return "<?php endforeach; unset(\$_from); else: ?>";
 
             case '/foreach':
                 if (array_pop($this->_foreachelse_stack))
                     return "<?php endif; ?>";
                 else
-                    return "<?php endforeach; endif; ?>";
+                    return "<?php endforeach; unset(\$_from); endif; ?>";
 
             case 'strip':
             case '/strip':
@@ -967,7 +967,7 @@
         foreach ($attrs as $attr_name => $attr_value) {
             switch ($attr_name) {
                 case 'loop':
-                    $output .= "{$section_props}['loop'] = is_array($attr_value) ? count($attr_value) : max(0, (int)$attr_value);\n";
+                    $output .= "{$section_props}['loop'] = is_array(\$_loop=$attr_value) ? count(\$_loop) : max(0, (int)\$_loop); unset(\$_loop);\n";
                     break;
 
                 case 'show':
@@ -1095,17 +1095,17 @@
         }
 
         if (isset($name)) {
-            $output .= "{$foreach_props}['total'] = count((array)$from);\n";
+            $output .= "{$foreach_props}['total'] = count(\$_from = (array)$from);\n";
             $output .= "{$foreach_props}['show'] = {$foreach_props}['total'] > 0;\n";
             $output .= "if ({$foreach_props}['show']):\n";
             $output .= "{$foreach_props}['iteration'] = 0;\n";
-            $output .= "    foreach ((array)$from as $key_part\$this->_tpl_vars['$item']):\n";
+            $output .= "    foreach (\$_from as $key_part\$this->_tpl_vars['$item']):\n";
             $output .= "        {$foreach_props}['iteration']++;\n";
             $output .= "        {$foreach_props}['first'] = ({$foreach_props}['iteration'] == 1);\n";
             $output .= "        {$foreach_props}['last']  = ({$foreach_props}['iteration'] == {$foreach_props}['total']);\n";
         } else {
-            $output .= "if (count((array)$from)):\n";
-            $output .= "    foreach ((array)$from as $key_part\$this->_tpl_vars['$item']):\n";
+            $output .= "if (count(\$_from = (array)$from)):\n";
+            $output .= "    foreach (\$_from as $key_part\$this->_tpl_vars['$item']):\n";
         }
         $output .= '?>';
 

-- 
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.