library/smarty/libs/plugins/modifiercompiler.strip.php
changeset 46 f11c31f7fa3e
parent 45 a56e7f9a0463
child 47 03388ec805b4
equal deleted inserted replaced
45:a56e7f9a0463 46:f11c31f7fa3e
     1 <?php
       
     2 /**
       
     3  * Smarty plugin
       
     4  *
       
     5  * @package    Smarty
       
     6  * @subpackage PluginsModifierCompiler
       
     7  */
       
     8 
       
     9 /**
       
    10  * Smarty strip modifier plugin
       
    11  * Type:     modifier<br>
       
    12  * Name:     strip<br>
       
    13  * Purpose:  Replace all repeated spaces, newlines, tabs
       
    14  *              with a single space or supplied replacement string.<br>
       
    15  * Example:  {$var|strip} {$var|strip:"&nbsp;"}<br>
       
    16  * Date:     September 25th, 2002
       
    17  *
       
    18  * @link   http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
       
    19  * @author Uwe Tews
       
    20  *
       
    21  * @param array $params parameters
       
    22  *
       
    23  * @return string with compiled code
       
    24  */
       
    25 
       
    26 function smarty_modifiercompiler_strip($params) {
       
    27     if (!isset($params[1])) {
       
    28         $params[1] = "' '";
       
    29     }
       
    30 
       
    31     return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
       
    32 }