/** * @see \Ableron\Core\Template\Plugins\Interfaces\CompilerPluginInterface::compileOpeningTag() */ public function compileOpeningTag(TemplateCompiler $templateCompiler) { // check whether last opened tag is an if-tag if ($templateCompiler->getLastCompilerPluginTagParameter('tagName') !== 'if') { throw new SystemException(sprintf('Unexpected {elseif} in template "%s" on line %s', $templateCompiler->getCurrentTemplateName(), $templateCompiler->getCurrentLineNumber()), 0, E_USER_ERROR, __FILE__, __LINE__); } // compile the tag return sprintf('<?php } elseif (%s) { ?>', $this->getTag()->getArgumentString()); }
/** * @see \Ableron\Core\Template\Plugins\Interfaces\CompilerPluginInterface::compileOpeningTag() */ public function compileOpeningTag(TemplateCompiler $templateCompiler) { // get parent foreach-tag $foreachTag = $templateCompiler->getLastCompilerPluginTagParameter('compilerPlugin')->getTag(); // check whether last opened tag is a foreach-tag if ($foreachTag->getTagName() !== 'foreach') { throw new SystemException(sprintf('Unexpected {foreachelse} in template "%s" on line %s', $templateCompiler->getCurrentTemplateName(), $templateCompiler->getCurrentLineNumber()), 0, E_USER_ERROR, __FILE__, __LINE__); } // extract items from foreach-tag argument string $items = preg_replace('#\\s*(.+?)\\s+as\\s+.*$#', '$1', $foreachTag->getArgumentString()); // close foreach-tag and use if-statement to check for empty foreach-input return sprintf('<?php } ?>%s<?php if (empty(%s)) { ?>', StringUtil::CHAR_LINE_FEED, $items); }
/** * @see \Ableron\Core\Template\Plugins\Interfaces\CompilerPluginInterface::compileClosingTag() */ public function compileClosingTag(TemplateCompiler $templateCompiler) { throw new SystemException(sprintf('Unknown tag {/%s} in template "%s" on line %s', $this->getTag()->getTagName(), $templateCompiler->getCurrentTemplateName(), $templateCompiler->getCurrentLineNumber()), 0, E_USER_ERROR, __FILE__, __LINE__); }