当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPTAL_Php_CodeWriter::pushContext方法代码示例

本文整理汇总了PHP中PHPTAL_Php_CodeWriter::pushContext方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPTAL_Php_CodeWriter::pushContext方法的具体用法?PHP PHPTAL_Php_CodeWriter::pushContext怎么用?PHP PHPTAL_Php_CodeWriter::pushContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPTAL_Php_CodeWriter的用法示例。


在下文中一共展示了PHPTAL_Php_CodeWriter::pushContext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: before

 public function before(PHPTAL_Php_CodeWriter $codewriter)
 {
     $this->var = $codewriter->createTempVariable();
     // alias to repeats handler to avoid calling extra getters on each variable access
     $codewriter->doSetVar($this->var, '$ctx->repeat');
     list($varName, $expression) = $this->parseSetExpression($this->expression);
     $code = $codewriter->evaluateExpression($expression);
     // instantiate controller using expression
     $codewriter->doSetVar($this->var . '->' . $varName, 'new PHPTAL_RepeatController(' . $code . ')' . "\n");
     $codewriter->pushContext();
     // Lets loop the iterator with a foreach construct
     $codewriter->doForeach('$ctx->' . $varName, $this->var . '->' . $varName);
 }
开发者ID:rafalenden,项目名称:KioCMS,代码行数:13,代码来源:Repeat.php

示例2: before

 public function before(PHPTAL_Php_CodeWriter $codewriter)
 {
     $expressions = $codewriter->splitExpression($this->expression);
     $definesAnyNonGlobalVars = false;
     foreach ($expressions as $exp) {
         list($defineScope, $defineVar, $expression) = $this->parseExpression($exp);
         if (!$defineVar) {
             continue;
         }
         $this->_defineScope = $defineScope;
         if ($defineScope != 'global') {
             $definesAnyNonGlobalVars = true;
         }
         // <span tal:define="global foo" /> should be invisible, but <img tal:define="bar baz" /> not
         if ($this->_defineScope != 'global' && !$this->_pushedContext) {
             $codewriter->pushContext();
             $this->_pushedContext = true;
         }
         $this->_defineVar = $defineVar;
         if ($expression === null) {
             // no expression give, use content of tag as value for newly defined
             // var.
             $this->bufferizeContent($codewriter);
             continue;
         }
         $code = $codewriter->evaluateExpression($expression);
         if (is_array($code)) {
             $this->chainedDefine($codewriter, $code);
         } elseif ($code == PHPTAL_Php_TalesInternal::NOTHING_KEYWORD) {
             $this->doDefineVarWith($codewriter, 'null');
         } else {
             $this->doDefineVarWith($codewriter, $code);
         }
     }
     // if the content of the tag was buffered or the tag has nothing to tell, we hide it.
     if ($this->_buffered || !$definesAnyNonGlobalVars && !$this->phpelement->hasRealContent() && !$this->phpelement->hasRealAttributes()) {
         $this->phpelement->hidden = true;
     }
 }
开发者ID:rafalenden,项目名称:KioCMS,代码行数:39,代码来源:Define.php


注:本文中的PHPTAL_Php_CodeWriter::pushContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。