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

From: Date: Thu, 17 Apr 2003 15:20:19 +0000
Subject: cvs: smarty / NEWS /libs Smarty_Compiler.class.php
Groups: php.smarty.cvs 
Request: Send a blank email to php-smarty-cvs+get-529@lists.php.net to get a copy of this message
mohrt Thu Apr 17 11:20:19 2003 EDT Modified files: /smarty NEWS /smarty/libs Smarty_Compiler.class.php Log: corrected output with Smarty comments Index: smarty/NEWS diff -u smarty/NEWS:1.339 smarty/NEWS:1.340 --- smarty/NEWS:1.339 Thu Apr 17 10:51:45 2003 +++ smarty/NEWS Thu Apr 17 11:20:19 2003 @@ -1,4 +1,5 @@ - - fixed bug with {strip} and PHP tag newlines (Monte) + - corrected output with smarty comments (Monte) + - corrected output with {strip} and PHP tag newlines (Monte) - added possibility to register function-callbacks as "array(&$obj, 'method)" this affects register_function(), -block, -compiler_function, -modifier, -prefilter, -postfilter, -outputfilter-functions() and $cache_handler_func Index: smarty/libs/Smarty_Compiler.class.php diff -u smarty/libs/Smarty_Compiler.class.php:1.207 smarty/libs/Smarty_Compiler.class.php:1.208 --- smarty/libs/Smarty_Compiler.class.php:1.207 Thu Apr 17 10:50:49 2003 +++ smarty/libs/Smarty_Compiler.class.php Thu Apr 17 11:20:19 2003 @@ -39,7 +39,7 @@ * @package Smarty */ -/* $Id: Smarty_Compiler.class.php,v 1.207 2003/04/17 14:50:49 mohrt Exp $ */ +/* $Id: Smarty_Compiler.class.php,v 1.208 2003/04/17 15:20:19 mohrt Exp $ */ class Smarty_Compiler extends Smarty { @@ -238,25 +238,33 @@ } /* Annihilate the comments. */ - $template_source = preg_replace("!({$ldq})\*(.*?)\*({$rdq})!se", - "'\\1*'.str_repeat(\"\n\", substr_count('\\2', \"\n\")) .'*\\3'", + + $_comment_search = array( + "!(\r|\r\n|\n)({$ldq})\*(.*?)\*({$rdq})(\r|\r\n|\n)!s", + "!({$ldq})\*(.*?)\*({$rdq})!s"); + $_comment_replace = array( + '\\1', + ''); + + $template_source = preg_replace($_comment_search, + $_comment_replace, $template_source); /* Pull out the literal blocks. */ - preg_match_all("!{$ldq}literal{$rdq}(.*?){$ldq}/literal{$rdq}!s", $template_source, $match); - $this->_literal_blocks = $match[1]; + preg_match_all("!{$ldq}literal{$rdq}(.*?){$ldq}/literal{$rdq}!s", $template_source, $_match); + $this->_literal_blocks = $_match[1]; $template_source = preg_replace("!{$ldq}literal{$rdq}(.*?){$ldq}/literal{$rdq}!s", $this->quote_replace($this->left_delimiter.'literal'.$this->right_delimiter), $template_source); /* Pull out the php code blocks. */ - preg_match_all("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s", $template_source, $match); - $this->_php_blocks = $match[1]; + preg_match_all("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s", $template_source, $_match); + $this->_php_blocks = $_match[1]; $template_source = preg_replace("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s", $this->quote_replace($this->left_delimiter.'php'.$this->right_delimiter), $template_source); /* Gather all template tags. */ - preg_match_all("!{$ldq}\s*(.*?)\s*{$rdq}!s", $template_source, $match); - $template_tags = $match[1]; + preg_match_all("!{$ldq}\s*(.*?)\s*{$rdq}!s", $template_source, $_match); + $template_tags = $_match[1]; /* Split content by template tags to obtain non-template content. */ $text_blocks = preg_split("!{$ldq}.*?{$rdq}!s", $template_source); @@ -379,10 +387,6 @@ */ function _compile_tag($template_tag) { - - /* Matched comment. */ - if ($template_tag{0} == '*' && $template_tag{strlen($template_tag) - 1} == '*') - return ''; /* Split tag into two three parts: command, command modifiers and the arguments. */ if(! preg_match('/^(?:(' . $this->_obj_call_regexp . '|' . $this->_var_regexp

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