Implemented support for substr, implode and json_encode as modifiers. (#940)

* Implemented support for substr, implode and json_encode as modifiers. Fixes #939
* Added split and join in favor of explode and implode modifiers.
* Documented all available modifiers
This commit is contained in:
Simon Wisselink
2024-02-26 14:35:19 +01:00
committed by GitHub
parent 2b0ba0eabc
commit 41d80b99ac
29 changed files with 723 additions and 70 deletions
@@ -0,0 +1,14 @@
<?php
namespace Smarty\Compile\Modifier;
/**
* Smarty json_encode modifier plugin
*/
class JsonEncodeModifierCompiler extends Base {
public function compile($params, \Smarty\Compiler\Template $compiler) {
return 'json_encode(' . $params[0] . (isset($params[1]) ? ', (int) ' . $params[1] : '') . ')';
}
}