public function talesChainPart(PHPTAL_Php_TalesChainExecutor $executor, $exp, $islast) { if (!$islast) { $var = $executor->getCodeWriter()->createTempVariable(); $executor->doIf('!phptal_isempty(' . $var . ' = ' . $exp . ')'); $this->doEchoAttribute($executor->getCodeWriter(), $var); $executor->getCodeWriter()->recycleTempVariable($var); } else { $executor->doElse(); $this->doEchoAttribute($executor->getCodeWriter(), $exp); } }
public function talesChainPart(PHPTAL_Php_TalesChainExecutor $executor, $exp, $islast) { // check if the expression is empty if ($exp !== 'false') { $this->expressions[] = '!phptal_isempty(' . $exp . ')'; } if ($islast) { // for the last one in the chain build a ORed condition $executor->getCodeWriter()->doIf(implode(' || ', $this->expressions)); // The executor will always end an if so we output a dummy if $executor->doIf('false'); } }
public function talesChainPart(PHPTAL_Php_TalesChainExecutor $executor, $exp, $islast) { $codewriter = $executor->getCodeWriter(); $escape = !($this->_echoType == PHPTAL_Php_Attribute::ECHO_STRUCTURE); $exp = $codewriter->getTranslatorReference() . "->translate({$exp}, " . ($escape ? 'true' : 'false') . ')'; if (!$islast) { $var = $codewriter->createTempVariable(); $executor->doIf('!phptal_isempty(' . $var . ' = ' . $exp . ')'); $codewriter->pushCode("echo {$var}"); $codewriter->recycleTempVariable($var); } else { $executor->doElse(); $codewriter->pushCode("echo {$exp}"); } }
public function talesChainPart(PHPTAL_Php_TalesChainExecutor $executor, $exp, $islast) { if ($this->_defineScope == 'global') { $var = '$tpl->getGlobalContext()->' . $this->_defineVar; } else { $var = '$ctx->' . $this->_defineVar; } $cw = $executor->getCodeWriter(); if (!$islast) { // must use temp variable, because expression could refer to itself $tmp = $cw->createTempVariable(); $executor->doIf('(' . $tmp . ' = ' . $exp . ') !== null'); $cw->doSetVar($var, $tmp); $cw->recycleTempVariable($tmp); } else { $executor->doIf('(' . $var . ' = ' . $exp . ') !== null'); } }
public function talesChainPart(PHPTAL_Php_TalesChainExecutor $executor, $exp, $islast) { $codewriter = $executor->getCodeWriter(); if (!$islast) { $condition = "!phptal_isempty({$this->_attkey} = ({$exp}))"; } else { $condition = "NULL !== ({$this->_attkey} = ({$exp}))"; } $executor->doIf($condition); if ($this->_echoType == PHPTAL_Php_Attribute::ECHO_STRUCTURE) { $value = $codewriter->stringifyCode($this->_attkey); } else { $value = $codewriter->escapeCode($this->_attkey); } $codewriter->doSetVar($this->_attkey, $codewriter->str(" {$this->_attribute}=\"") . ".{$value}.'\"'"); }
public function talesChainDefaultKeyword(PHPTAL_Php_TalesChainExecutor $executor) { $executor->doElse(); $this->generateDefault($executor->getCodeWriter()); $executor->breakChain(); }