From 32b9ebfa6814a6048a5631974336d1721938e667 Mon Sep 17 00:00:00 2001 From: mohrt Date: Thu, 25 Oct 2001 19:04:05 +0000 Subject: [PATCH] fixed problem with newline at the end of compiled templates --- NEWS | 1 + Smarty.class.php | 2 +- Smarty_Compiler.class.php | 4 ++++ libs/Smarty.class.php | 2 +- libs/Smarty_Compiler.class.php | 4 ++++ 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index b1df787c..ffdd1f50 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ + - fixed problem with newline at the end of included templates (Monte, Andrei) - added feature to regenerate cache if compile_check is enabled and an involved template or config file gets modified (Monte) - added DEBUG execution times to included files (Monte) diff --git a/Smarty.class.php b/Smarty.class.php index 4bb5e9bb..cc05b59e 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -198,7 +198,7 @@ class Smarty var $_compile_id = null; // for different compiled templates var $_smarty_debug_id = 'SMARTY_DEBUG'; // text in URL to enable debug mode var $_smarty_debug_info = array(); // debugging information for debug console - var $_cache_info = array(); // templates that make up a cache file + var $_cache_info = array(); // info that makes up a cache file /*======================================================================*\ diff --git a/Smarty_Compiler.class.php b/Smarty_Compiler.class.php index 381d6eac..770049a8 100644 --- a/Smarty_Compiler.class.php +++ b/Smarty_Compiler.class.php @@ -163,6 +163,10 @@ class Smarty_Compiler extends Smarty { $template_header .= " compiled from ".$tpl_file." */ ?>\n"; $template_compiled = $template_header.$template_compiled; + // remove \n from the end of the file, if any + if ( $template_compiled{strlen($template_compiled)-1} == "\n" ) { + $template_compiled = substr($template_compiled,0,-1); + } // run compiled template through postfilter functions if (is_array($this->postfilter_funcs) && count($this->postfilter_funcs) > 0) { diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 4bb5e9bb..cc05b59e 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -198,7 +198,7 @@ class Smarty var $_compile_id = null; // for different compiled templates var $_smarty_debug_id = 'SMARTY_DEBUG'; // text in URL to enable debug mode var $_smarty_debug_info = array(); // debugging information for debug console - var $_cache_info = array(); // templates that make up a cache file + var $_cache_info = array(); // info that makes up a cache file /*======================================================================*\ diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index 381d6eac..770049a8 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -163,6 +163,10 @@ class Smarty_Compiler extends Smarty { $template_header .= " compiled from ".$tpl_file." */ ?>\n"; $template_compiled = $template_header.$template_compiled; + // remove \n from the end of the file, if any + if ( $template_compiled{strlen($template_compiled)-1} == "\n" ) { + $template_compiled = substr($template_compiled,0,-1); + } // run compiled template through postfilter functions if (is_array($this->postfilter_funcs) && count($this->postfilter_funcs) > 0) {