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


PHP Element::compile方法代码示例

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


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

示例1: compile

 public function compile(\Xtpl\Compiler $compiler, $cwd)
 {
     if ($this->hasAttribute('NAME')) {
         $name = $this->getAttribute('NAME');
         $mode = $this->hasAttribute('MODE') ? $this->getAttribute('MODE') : 'replace';
         foreach ($this->findAll('BLOCK', array('NAME' => $this->getAttribute('NAME'))) as $result) {
             if ($result instanceof BlockElement && $result->isTarget()) {
                 switch ($mode) {
                     default:
                     case 'replace':
                         $result->setChildren(array($this));
                         break;
                     case 'append':
                         $result->addChild($this);
                         break;
                     case 'prepend':
                         $result->prependChild($this);
                         break;
                 }
             }
         }
         if (!$this->getParent() instanceof self) {
             $this->setAsTarget();
         }
     }
     return parent::compile($compiler, $cwd);
 }
开发者ID:torbenkoehn,项目名称:php-xtpl,代码行数:27,代码来源:BlockElement.php

示例2: compile

 public function compile(\Xtpl\Compiler $compiler, $cwd)
 {
     if (!$this->isCompiled()) {
         if ($this->hasParent() && $this->getParent() instanceof IfElement) {
             $this->prependPhp("else:");
         }
     }
     return parent::compile($compiler, $cwd);
 }
开发者ID:torbenkoehn,项目名称:php-xtpl,代码行数:9,代码来源:ElseElement.php

示例3: compile

 public function compile(\Xtpl\Compiler $compiler, $cwd)
 {
     if (!$this->isCompiled()) {
         if ($this->hasAttribute('EXTENDS')) {
             $extendPath = $cwd . DIRECTORY_SEPARATOR . $this->getAttribute('EXTENDS');
             $xtpl = $compiler->compileFile($extendPath);
             //Incorporate trees
             $xtpl->addChild($this);
         }
     }
     return parent::compile($compiler, $cwd);
 }
开发者ID:torbenkoehn,项目名称:php-xtpl,代码行数:12,代码来源:XtplElement.php

示例4: compile

 public function compile(\Xtpl\Compiler $compiler, $cwd)
 {
     if (!$this->isCompiled()) {
         $expr = '';
         if ($this->hasAttribute('COND')) {
             $expr = $this->getAttribute('COND');
         } else {
             if ($this->hasAttribute('NOT-COND')) {
                 $expr = '!( ' . $this->getAttribute('NOT-COND') . ' )';
             } else {
                 if ($this->hasAttribute('EMPTY')) {
                     $expr = 'empty( $' . str_replace('.', '->', $this->getAttribute('EMPTY')) . ' )';
                 } else {
                     if ($this->hasAttribute('NOT-EMPTY')) {
                         $expr = '!empty( $' . str_replace('.', '->', $this->getAttribute('NOT-EMPTY')) . ' )';
                     } else {
                         if ($this->hasAttribute('SET')) {
                             $expr = 'isset( $' . str_replace('.', '->', $this->getAttribute('SET')) . ' )';
                         } else {
                             if ($this->hasAttribute('NOT-SET')) {
                                 $expr = '!isset( $' . str_replace('.', '->', $this->getAttribute('NOT-SET')) . ' )';
                             }
                         }
                     }
                 }
             }
         }
         if (!empty($expr)) {
             switch ($this->getTagName()) {
                 default:
                 case 'IF':
                     $this->prependPhp("if( {$expr} ):");
                     //Make sure elses and ifelses are the very last children
                     $else = $this->find('ELSE');
                     $elseIf = $this->find('ELSE-IF');
                     if (!empty($elseIf)) {
                         $this->addChild($elseIf[0]);
                     }
                     if (!empty($else)) {
                         $this->addChild($else[0]);
                     }
                     $this->addPhp('endif;');
                     break;
                 case 'ELSE-IF':
                     //make sure this one is at the end the children of its parent, but before the closing php
                     $this->prependPhp("elseif( {$expr} ):");
                     break;
             }
         }
     }
     return parent::compile($compiler, $cwd);
 }
开发者ID:torbenkoehn,项目名称:php-xtpl,代码行数:52,代码来源:IfElement.php

示例5: compile

 public function compile(\Xtpl\Compiler $compiler, $cwd)
 {
     if (!$this->isCompiled()) {
         if ($this->hasAttribute('FILE')) {
             $includePath = $cwd . DIRECTORY_SEPARATOR . $this->getAttribute('FILE');
             $xtpl = $compiler->compileFile($includePath);
             //Apply arguments on templates (Even on extended ones, yay!)
             $this->applyArgs($xtpl);
             $this->addChild($xtpl);
         }
     }
     return parent::compile($compiler, $cwd);
 }
开发者ID:torbenkoehn,项目名称:php-xtpl,代码行数:13,代码来源:IncludeElement.php

示例6: compile

 public function compile(\Xtpl\Compiler $compiler, $cwd)
 {
     if (!$this->isCompiled()) {
         if ($this->hasAttribute('NAME')) {
             if ($this->hasAttribute('VALUE')) {
                 $this->addPhp('$' . $this->getAttribute('NAME') . ' = \'' . $this->getAttribute('VALUE') . '\';');
             } else {
                 $this->addPhp('echo $' . $this->getAttribute('NAME') . ';');
             }
         }
     }
     return parent::compile($compiler, $cwd);
 }
开发者ID:torbenkoehn,项目名称:php-xtpl,代码行数:13,代码来源:VarElement.php

示例7: compile

 public function compile(\Xtpl\Compiler $compiler, $cwd)
 {
     if (!$this->isCompiled()) {
         if ($this->getParent() instanceof PanelElement) {
             $this->setTagName('DIV');
             $this->addClass('panel-body');
             //Check if this is an accordion
             if ($this->getParent(2) instanceof AccordionElement) {
                 $this->wrap(new Panel\CollapseElement());
             }
         }
     }
     return parent::compile($compiler, $cwd);
 }
开发者ID:torbenkoehn,项目名称:php-xtpl,代码行数:14,代码来源:BodyElement.php

示例8: compile

 public function compile(\Xtpl\Compiler $compiler, $cwd)
 {
     if (!$this->isCompiled()) {
         if ($this->getParent() instanceof PanelElement) {
             if ($this->hasAttribute('SIZE') || $this->getParent(2) instanceof AccordionElement) {
                 $this->ignoreAttribute('SIZE');
                 $size = $this->hasAttribute('SIZE') ? intval($this->getAttribute('SIZE')) : 4;
                 $h = $this->wrapInner(new TitleElement(array('SIZE' => $size)));
                 if ($this->getParent(2) instanceof AccordionElement) {
                     $a = new AElement(array('DATA-TOGGLE' => 'collapse', 'DATA-PARENT' => '#' . $this->getParent(2)->getAttribute('ID')));
                     $h->wrapInner($a);
                 }
             }
             $this->setTagName('DIV');
             $this->addClass('panel-heading');
         }
     }
     return parent::compile($compiler, $cwd);
 }
开发者ID:torbenkoehn,项目名称:php-xtpl,代码行数:19,代码来源:HeaderElement.php

示例9: compile

 public function compile(\Xtpl\Compiler $compiler, $cwd)
 {
     if (!$this->isCompiled()) {
         if ($this->hasAttribute('EACH') && $this->hasAttribute('AS')) {
             //it's a foreach( $arr as $key => $val ) loop
             $as = $this->hasAttribute('KEY') ? '$' . $this->getAttribute('KEY') . ' => $' . $this->getAttribute('AS') : '$' . $this->getAttribute('AS');
             $this->prependPhp('foreach( $' . $this->getAttribute('EACH') . ' as ' . $as . ' ):');
             $this->addPhp('endforeach;');
         }
         if ($this->hasAttribute('TIMES')) {
             $start = $this->hasAttribute('FIRST') ? intval($this->getAttribute('FIRST')) : 0;
             $as = $this->hasAttribute('AS') ? $this->getAttribute('AS') : '_xtplLoopCounter';
             $end = $start + intval($this->getAttribute('TIMES'));
             $this->prependPhp('for( $' . $as . ' = ' . $start . '; $' . $as . ' < ' . $end . '; $' . $as . '++ ):');
             $this->addPhp('endfor;');
         }
     }
     return parent::compile($compiler, $cwd);
 }
开发者ID:torbenkoehn,项目名称:php-xtpl,代码行数:19,代码来源:ForElement.php


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