diff --git a/NEWS b/NEWS
index b981bcc7..e2916703 100644
--- a/NEWS
+++ b/NEWS
@@ -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)
diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php
index 81da18c1..2d6481ba 100644
--- a/libs/Smarty_Compiler.class.php
+++ b/libs/Smarty_Compiler.class.php
@@ -330,6 +330,26 @@ class Smarty_Compiler extends Smarty {
}
$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 @@ class Smarty_Compiler extends Smarty {
else
return "";
+ 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");
diff --git a/libs/plugins/block.strip.php b/libs/plugins/block.strip.php
deleted file mode 100644
index bc092c82..00000000
--- a/libs/plugins/block.strip.php
+++ /dev/null
@@ -1,35 +0,0 @@
-
- * Name: strip
- * Purpose: strip unwanted white space from text
- * @link http://smarty.php.net/manual/en/language.function.strip.php {strip}
- * (Smarty online manual)
- * @param array unused, no parameters for this block
- * @param string content of {strip}{/strip} tags
- * @param Smarty clever method emulation
- * @return string $content stripped of whitespace
- */
-function smarty_block_strip($params, $content, &$smarty)
-{
- /* Reformat data between 'strip' and '/strip' tags, removing spaces, tabs and newlines. */
- $_strip_search = array(
- "![\t ]+$|^[\t ]+!m", // remove leading/trailing space chars
- '%[\r\n]+%m'); // remove CRs and newlines
- $_strip_replace = array(
- '',
- '');
- return preg_replace($_strip_search, $_strip_replace, $content);
-}
-
-/* vim: set expandtab: */
-
-?>