Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
Merge branch 'pu/cw/twigPregReplace' into '2022.11'
Browse files Browse the repository at this point in the history
feature(Tinebase): have preg_replace as twig filter

See merge request tine20/tine20!1939
  • Loading branch information
corneliusweiss committed Mar 17, 2022
2 parents d1f363b + adfe7d5 commit b598bdf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tine20/Tinebase/Twig.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ protected function _addTwigFunctions()
$this->_twigEnvironment->addFilter(new Twig_SimpleFilter('transliterate', function($str) {
return transliterator_transliterate('Any-Latin; Latin-ASCII', $str);
}));

$this->_twigEnvironment->addFilter(new Twig_SimpleFilter('preg_replace', function($subject, $pattern, $replacement, int $limit=-1, int $count=null) {
return preg_replace($pattern, $replacement, $subject, $limit, $count);
}));
$this->_twigEnvironment->addFunction(new Twig_SimpleFunction('translate',
function ($str) use($locale, $translate) {
$translatedStr = $translate->translate($str, $locale);
Expand Down

0 comments on commit b598bdf

Please sign in to comment.