Smarty v5 update test, initial code setup
This commit is contained in:
24
src/Compile/Modifier/StripModifierCompiler.php
Normal file
24
src/Compile/Modifier/StripModifierCompiler.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace Smarty\Compile\Modifier;
|
||||
/**
|
||||
* Smarty strip modifier plugin
|
||||
* Type: modifier
|
||||
* Name: strip
|
||||
* Purpose: Replace all repeated spaces, newlines, tabs
|
||||
* with a single space or supplied replacement string.
|
||||
* Example: {$var|strip} {$var|strip:" "}
|
||||
* Date: September 25th, 2002
|
||||
*
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
class StripModifierCompiler extends Base {
|
||||
|
||||
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||
if (!isset($params[ 1 ])) {
|
||||
$params[ 1 ] = "' '";
|
||||
}
|
||||
return "preg_replace('!\s+!" . \Smarty\Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user