From d216b3147bc3f37cf2337acab5767c6a4f74aa2e Mon Sep 17 00:00:00 2001 From: emkael Date: Mon, 31 Oct 2016 21:58:33 +0100 Subject: * PHPTAL library --- .../PHPTAL/Php/Attribute/METAL/DefineSlot.php | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 lib/phptal/PHPTAL/Php/Attribute/METAL/DefineSlot.php (limited to 'lib/phptal/PHPTAL/Php/Attribute/METAL/DefineSlot.php') diff --git a/lib/phptal/PHPTAL/Php/Attribute/METAL/DefineSlot.php b/lib/phptal/PHPTAL/Php/Attribute/METAL/DefineSlot.php new file mode 100644 index 0000000..010849a --- /dev/null +++ b/lib/phptal/PHPTAL/Php/Attribute/METAL/DefineSlot.php @@ -0,0 +1,70 @@ + + * @author Kornel LesiƄski + * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License + * @version SVN: $Id$ + * @link http://phptal.org/ + */ + +/** + * METAL Specification 1.0 + * + * argument ::= Name + * + * Example: + * + * + * + * + *
Links
+ * A Link + *
+ * + * PHPTAL: (access to slots may be renamed) + * + * + * + * + * + * slots->links)): ? > + * slots->links ? > + * + * + *
Links
+ * A Link + *
+ * + * + * @package PHPTAL + * @subpackage Php.attribute.metal + * @author Laurent Bedubourg + */ +class PHPTAL_Php_Attribute_METAL_DefineSlot extends PHPTAL_Php_Attribute +{ + private $tmp_var; + + public function before(PHPTAL_Php_CodeWriter $codewriter) + { + $this->tmp_var = $codewriter->createTempVariable(); + + $codewriter->doSetVar($this->tmp_var, $codewriter->interpolateTalesVarsInString($this->expression)); + $codewriter->doIf('$ctx->hasSlot('.$this->tmp_var.')'); + $codewriter->pushCode('$ctx->echoSlot('.$this->tmp_var.')'); + $codewriter->doElse(); + } + + public function after(PHPTAL_Php_CodeWriter $codewriter) + { + $codewriter->doEnd('if'); + + $codewriter->recycleTempVariable($this->tmp_var); + } +} + -- cgit v1.2.3