Line | |
---|
1 | <?php |
---|
2 | /** |
---|
3 | * Smarty plugin |
---|
4 | * |
---|
5 | * @package Smarty |
---|
6 | * @subpackage PluginsModifierCompiler |
---|
7 | */ |
---|
8 | |
---|
9 | /** |
---|
10 | * Smarty default modifier plugin |
---|
11 | * |
---|
12 | * Type: modifier<br> |
---|
13 | * Name: default<br> |
---|
14 | * Purpose: designate default value for empty variables |
---|
15 | * |
---|
16 | * @link http://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual) |
---|
17 | * @author Uwe Tews |
---|
18 | * @param array $params parameters |
---|
19 | * @return string with compiled code |
---|
20 | */ |
---|
21 | function smarty_modifiercompiler_default ($params, $compiler) |
---|
22 | { |
---|
23 | $output = $params[0]; |
---|
24 | if (!isset($params[1])) { |
---|
25 | $params[1] = "''"; |
---|
26 | } |
---|
27 | |
---|
28 | array_shift($params); |
---|
29 | foreach ($params as $param) { |
---|
30 | $output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)'; |
---|
31 | } |
---|
32 | return $output; |
---|
33 | } |
---|
34 | |
---|
35 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.