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

33 lines
816 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
}
for ($i = 1, $cnt = count($params); $i < $cnt; $i++) {
2010-09-22 13:06:47 +00:00
$output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $params[$i] . ' : $tmp)';
2011-09-16 14:19:56 +00:00
}
return $output;
2011-09-16 14:19:56 +00:00
}
?>