modifier.prepend.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2020 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
11 
12 /**
13  * Prepend a value, if the string is not empty
14  *
15  * Example:
16  * @code
17  * {$text|prepend:"- "}
18  * @endcode
19  *
20  * @param $string The string to prepend to
21  * @param $prefix The value to prepend
22  * @return String
23  */
24 function smarty_modifier_prepend($string, $prefix) {
25  return strlen($string) > 0 ? $prefix.$string : "";
26 }
27 ?>