modifiercompiler.strip.php 850 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * Smarty plugin
  4. *
  5. * @package Smarty
  6. * @subpackage PluginsModifierCompiler
  7. */
  8. /**
  9. * Smarty strip modifier plugin
  10. *
  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. * @param array $params parameters
  21. * @return string with compiled code
  22. */
  23. function smarty_modifiercompiler_strip($params, $compiler)
  24. {
  25. if (!isset($params[1])) {
  26. $params[1] = "' '";
  27. }
  28. return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
  29. }
  30. ?>