mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
add strip block function file to repository
This commit is contained in:
30
libs/plugins/block.strip.php
Normal file
30
libs/plugins/block.strip.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Smarty plugin
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage plugins
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty textformat plugin
|
||||||
|
*
|
||||||
|
* Type: block function<br>
|
||||||
|
* Name: strip<br>
|
||||||
|
* Purpose: strip unwanted white space from text<br>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function smarty_block_strip($params, $content, &$this)
|
||||||
|
{
|
||||||
|
/* 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: */
|
||||||
|
|
||||||
|
?>
|
Reference in New Issue
Block a user