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


PHP PHPTAL_Php_CodeWriter::splitExpression方法代码示例

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


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

示例1: before

 public function before(PHPTAL_Php_CodeWriter $codewriter)
 {
     // split attributes to translate
     foreach ($codewriter->splitExpression($this->expression) as $exp) {
         list($qname, $key) = $this->parseSetExpression($exp);
         // if the translation key is specified and not empty (but may be '0')
         if (strlen($key)) {
             // we use it and replace the tag attribute with the result of the translation
             $code = $this->_getTranslationCode($codewriter, $key);
         } else {
             $attr = $this->phpelement->getAttributeNode($qname);
             if (!$attr) {
                 throw new PHPTAL_TemplateException("Unable to translate attribute {$qname}, because there is no translation key specified", $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());
             }
             if ($attr->getReplacedState() === PHPTAL_Dom_Attr::NOT_REPLACED) {
                 $code = $this->_getTranslationCode($codewriter, $attr->getValue());
             } elseif ($attr->getReplacedState() === PHPTAL_Dom_Attr::VALUE_REPLACED && $attr->getOverwrittenVariableName()) {
                 // sadly variables won't be interpolated in this translation
                 $code = 'echo ' . $codewriter->escapeCode('$_translator->translate(' . $attr->getOverwrittenVariableName() . ', false)');
             } else {
                 throw new PHPTAL_TemplateException("Unable to translate attribute {$qname}, because other TAL attributes are using it", $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());
             }
         }
         $this->phpelement->getOrCreateAttributeNode($qname)->overwriteValueWithCode($code);
     }
 }
开发者ID:jo-m,项目名称:ecamp3,代码行数:26,代码来源:Attributes.php

示例2: before

 public function before(PHPTAL_Php_CodeWriter $codewriter)
 {
     // split attributes using ; delimiter
     $attrs = $codewriter->splitExpression($this->expression);
     foreach ($attrs as $exp) {
         list($qname, $expression) = $this->parseSetExpression($exp);
         if ($expression) {
             $this->prepareAttribute($codewriter, $qname, $expression);
         }
     }
 }
开发者ID:rafalenden,项目名称:KioCMS,代码行数:11,代码来源:Attributes.php

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