modifiercompiler.indent.php 711 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * Smarty plugin
  4. * @package Smarty
  5. * @subpackage PluginsModifierCompiler
  6. */
  7. /**
  8. * Smarty indent modifier plugin
  9. *
  10. * Type: modifier<br>
  11. * Name: indent<br>
  12. * Purpose: indent lines of text
  13. *
  14. * @link http://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual)
  15. * @author Uwe Tews
  16. * @param array $params parameters
  17. * @return string with compiled code
  18. */
  19. function smarty_modifiercompiler_indent($params, $compiler)
  20. {
  21. if (!isset($params[1])) {
  22. $params[1] = 4;
  23. }
  24. if (!isset($params[2])) {
  25. $params[2] = "' '";
  26. }
  27. return 'preg_replace(\'!^!m\',str_repeat(' . $params[2] . ',' . $params[1] . '),' . $params[0] . ')';
  28. }
  29. ?>