cvs: smarty /libs Smarty_Compiler.class.php
| From: | Monte Ohrt | Date: | Mon, 16 Jun 2003 14:38:57 +0000 |
| Subject: | cvs: smarty /libs Smarty_Compiler.class.php | ||
| Groups: | php.smarty.cvs | ||
| Request: | Send a blank email to php-smarty-cvs+get-646@lists.php.net to get a copy of this message | ||
mohrt Mon Jun 16 10:38:57 2003 EDT
Modified files:
/smarty/libs Smarty_Compiler.class.php
Log:
fix newline handling for template for all template tags
Index: smarty/libs/Smarty_Compiler.class.php
diff -u smarty/libs/Smarty_Compiler.class.php:1.236 smarty/libs/Smarty_Compiler.class.php:1.237
--- smarty/libs/Smarty_Compiler.class.php:1.236 Wed Jun 11 18:17:52 2003
+++ smarty/libs/Smarty_Compiler.class.php Mon Jun 16 10:38:57 2003
@@ -39,7 +39,7 @@
* @package Smarty
*/
-/* $Id: Smarty_Compiler.class.php,v 1.236 2003/06/11 22:17:52 messju Exp $ */
+/* $Id: Smarty_Compiler.class.php,v 1.237 2003/06/16 14:38:57 mohrt Exp $ */
/**
* Template compiling class
* @package Smarty
@@ -305,10 +305,14 @@
$this->_current_line_no += substr_count($template_tags[$i], "\n");
}
- $template_compiled = '';
-
+ $template_compiled = '';
+
/* Interleave the compiled contents and text blocks to get the final result. */
for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) {
+ if ($compiled_tags[$i] == '') {
+ // tag result empty, remove first newline from following text block
+ $text_blocks[$i+1] = preg_replace('!^(\r\n|\r|\n)!', '',
$text_blocks[$i+1]);
+ }
$template_compiled .= $text_blocks[$i].$compiled_tags[$i];
}
$template_compiled .= $text_blocks[$i];
@@ -552,8 +556,10 @@
*/
if ($found) {
if ($have_function) {
- $output = '<?php ' . call_user_func_array($plugin_func,
- array($tag_args, &$this)) . '
?>';
+ $output = call_user_func_array($plugin_func, array($tag_args, &$this));
+ if($output != '') {
+ $output = '<?php ' . $output . ' ?>';
+ }
} else {
$this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);
}
@@ -684,7 +690,11 @@
$this->_parse_modifiers($return, $tag_modifier);
}
- return '<?php echo ' . $return . " ; ?>\n";
+ if($_return != '') {
+ $_return = '<?php echo ' . $_return . ' ; ?>';
+ }
+
+ return $_return;
}
/**