예제 #1
0
 /**
  * @expectedException Apishka_Templater_Error_Syntax
  * @expectedMessage   Unexpected end of template
  */
 public function testEndOfTemplateLook()
 {
     $stream = new Apishka_Templater_TokenStream(array(new Apishka_Templater_Token(Apishka_Templater_Token::BLOCK_START_TYPE, 1, 1)));
     while (!$stream->isEOF()) {
         $stream->look();
         $stream->next();
     }
 }
예제 #2
0
파일: For.php 프로젝트: apishka/templater
 private function checkLoopUsageBody(Apishka_Templater_TokenStream $stream, Apishka_Templater_NodeAbstract $node)
 {
     if ($node instanceof Apishka_Templater_Node_Expression_GetAttr && $node->getNode('node') instanceof Apishka_Templater_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) {
         $attribute = $node->getNode('attribute');
         if ($attribute instanceof Apishka_Templater_Node_Expression_Constant && in_array($attribute->getAttribute('value'), array('length', 'revindex0', 'revindex', 'last'))) {
             throw new Apishka_Templater_Error_Syntax(sprintf('The "loop.%s" variable is not defined when looping with a condition.', $attribute->getAttribute('value')), $node->getLine(), $stream->getFilename());
         }
     }
     // should check for parent.loop.XXX usage
     if ($node instanceof Apishka_Templater_Node_For) {
         return;
     }
     foreach ($node as $n) {
         if (!$n) {
             continue;
         }
         $this->checkLoopUsageBody($stream, $n);
     }
 }