mirror of
https://github.com/smarty-php/smarty.git
synced 2026-08-09 23:11:30 +02:00
24 lines
529 B
PHP
24 lines
529 B
PHP
<?php
|
|
namespace Smarty\Compile\Modifier;
|
|
/**
|
|
* Smarty indent modifier plugin
|
|
* Type: modifier
|
|
* Name: indent
|
|
* Purpose: indent lines of text
|
|
*
|
|
* @author Uwe Tews
|
|
*/
|
|
|
|
class IndentModifierCompiler extends Base {
|
|
|
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
|
if (!isset($params[ 1 ])) {
|
|
$params[ 1 ] = 4;
|
|
}
|
|
if (!isset($params[ 2 ])) {
|
|
$params[ 2 ] = "' '";
|
|
}
|
|
return 'preg_replace(\'!^!m\',str_repeat(' . $params[ 2 ] . ',' . $params[ 1 ] . '),' . $params[ 0 ] . ')';
|
|
}
|
|
|
|
} |