예제 #1
0
 /**
  * Parse the next token
  *
  * @return void
  */
 protected function next()
 {
     $token = $this->currentToken();
     // current token has to be an identifier
     if ($token->type !== 'identifier') {
         throw $this->errorUnexpectedToken($token);
     }
     $this->tag->setName($token->getValue());
     $this->skipToken();
     // we use all tokens until a linebreak in the short tag
     $tokens = $this->getTokensUntilLinebreak();
     $attributeTokens = array();
     // retrieve all attribute tokens
     foreach ($tokens as $key => $token) {
         if ($token->type === 'assignText') {
             break;
         }
         $attributeTokens[] = $token;
         unset($tokens[$key]);
     }
     // now lets parse the attributes
     $this->tag->attributes = $this->parseAttributeTokens($attributeTokens);
     // reset the token array keys
     $tokens = array_values($tokens);
     if (!empty($tokens) && $tokens[0]->type === 'assignText') {
         unset($tokens[0]);
         $this->tag->addChild(new TextNode($this->parseChild('Expression', $tokens, false)));
     }
     // return the result
     return $this->node();
 }
예제 #2
0
파일: Tag.php 프로젝트: mario-deluna/tattoo
 /**
  * tests Parser
  */
 public function testTagWithAttributes()
 {
     $tag = new Tag();
     $tag->setName('input');
     $tag->attributes = array('name' => 'username', 'type' => 'text');
     $tag = $this->compile($tag);
     $this->assertContains("array('name' => 'username', 'type' => 'text')", $tag);
 }
예제 #3
0
 /**
  * tests Parser
  */
 public function testBasic()
 {
     $node = new Scope();
     $tag = new Tag();
     $tag->setName('button');
     $node->addChild($tag);
     $node = $this->compile($node);
     $this->assertContains("if (!isset(\$__tattoo_vars)) {", $node);
     $this->assertContains("\$__tattoo_vars = array();", $node);
 }