cvs: smarty / NEWS /libs Smarty_Compiler.class.php /libs/plugins block.strip.php

"Messju Mohr" <[email protected]>
Newsgroups gmane.comp.php.cvs.smarty
Message-ID <cvsmessju1061390916@cvsserver>
messju		Wed Aug 20 10:48:36 2003 EDT

  Removed files:               
    /smarty/libs/plugins	block.strip.php 

  Modified files:              
    /smarty	NEWS 
    /smarty/libs	Smarty_Compiler.class.php 
  Log:
  reverted {strip} from a block-plugin back into the compiler
  
  
Index: smarty/NEWS
diff -u smarty/NEWS:1.389 smarty/NEWS:1.390
--- smarty/NEWS:1.389	Thu Aug 14 06:59:30 2003
+++ smarty/NEWS	Wed Aug 20 10:48:34 2003
@@ -1,3 +1,4 @@
+  - moved {strip} back into the compiler (messju)
   - fixed config_load: handling of section-attribute and use of
     multiple config-files in one template (atu, messju)
 
Index: smarty/libs/Smarty_Compiler.class.php
diff -u smarty/libs/Smarty_Compiler.class.php:1.276 smarty/libs/Smarty_Compiler.class.php:1.277
--- smarty/libs/Smarty_Compiler.class.php:1.276	Mon Aug 18 05:28:02 2003
+++ smarty/libs/Smarty_Compiler.class.php	Wed Aug 20 10:48:35 2003
@@ -39,7 +39,7 @@
  * @package Smarty
  */
 
-/* $Id: Smarty_Compiler.class.php,v 1.276 2003/08/18 09:28:02 messju Exp $ */
+/* $Id: Smarty_Compiler.class.php,v 1.277 2003/08/20 14:48:35 messju Exp $ */
 
 /**
  * Template compiling class
@@ -330,6 +330,26 @@
         }
         $compiled_content .= $text_blocks[$i];
 
+        /* Reformat data between 'strip' and '/strip' tags, removing spaces, tabs and newlines. */
+        if (preg_match_all("!{$ldq}strip{$rdq}.*?{$ldq}/strip{$rdq}!s", $compiled_content, $_match)) {
+            $strip_tags = $_match[0];
+            $_strip_search = array(
+                '%([^\\\\]\?>)\n%', // remove newlines after PHP close tags
+                "!{$ldq}/?strip{$rdq}|[\t ]+$|^[\t ]+!m", // remove leading/trailing space chars
+                '%[\r\n]+%m', // remove CRs and newlines
+                '%([^\\\\]\?>)%'); // replace newlines after PHP close tags
+            $_strip_replace = array(
+                '\\1',
+                '',
+                '',
+                '\\1' . "\n");
+            $strip_tags_modified = preg_replace($_strip_search, $_strip_replace, $strip_tags);
+            for ($i = 0, $for_max = count($strip_tags); $i < $for_max; $i++)
+                $compiled_content = preg_replace("!{$ldq}strip{$rdq}.*?{$ldq}/strip{$rdq}!s",
+                                                  $this->quote_replace($strip_tags_modified[$i]),
+                                                  $compiled_content, 1);
+        }
+
         // remove \n from the end of the file, if any
         if (($_len=strlen($compiled_content)) && ($compiled_content{$_len - 1} == "\n" )) {
             $compiled_content = substr($compiled_content, 0, -1);
@@ -492,6 +512,9 @@
                 else
                     return "<?php endforeach; endif; ?>";
 
+            case 'strip':
+            case '/strip':
+                return $this->left_delimiter.$tag_command.$this->right_delimiter;
             case 'literal':
                 list (,$literal_block) = each($this->_literal_blocks);
                 $this->_current_line_no += substr_count($literal_block, "\n");



-- 
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.