Files
smarty/libs/plugins/modifiercompiler.default.php

35 lines
819 B
PHP
Raw Normal View History

<?php
/**
* Smarty plugin
2010-08-17 15:39:51 +00:00
*
* @package Smarty
* @subpackage PluginsModifierCompiler
*/
/**
* Smarty default modifier plugin
2011-09-16 14:19:56 +00:00
*
* Type: modifier<br>
* Name: default<br>
* Purpose: designate default value for empty variables
2011-09-16 14:19:56 +00:00
*
* @link http://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
* @author Uwe Tews
* @param array $params parameters
* @return string with compiled code
*/
function smarty_modifiercompiler_default ($params, $compiler)
{
$output = $params[0];
if (!isset($params[1])) {
$params[1] = "''";
2011-09-16 14:19:56 +00:00
}
array_shift($params);
foreach ($params as $param) {
$output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)';
2011-09-16 14:19:56 +00:00
}
return $output;
2011-09-16 14:19:56 +00:00
}
?>