public function enterTag(Tag $tag)
 {
     if ($tag->hasChilds() || $tag->hasContent()) {
         return;
     }
     if (in_array($tag->getTagName(), $this->autocloseTags)) {
         $tag->setFlag(Tag::FLAG_SELF_CLOSE);
     }
 }
예제 #2
0
 protected function createNodes()
 {
     $node = new Tag(array(), 'div', array());
     $this->assertFalse($node->hasChilds());
     $nodeB = new Tag(array(), 'div', array());
     $node->addChild($nodeB);
     $this->assertTrue($node->hasChilds());
     $this->assertSame($node, $nodeB->getParent());
     $nodeC = new Tag(array(), 'div', array());
     $node->addChild($nodeC);
     $this->assertSame(2, count($node->getChilds()));
     $this->assertSame($node, $nodeC->getParent());
     $this->assertSame(null, $nodeB->getPreviousSibling());
     $this->assertSame($nodeC, $nodeB->getNextSibling());
     $this->assertSame($nodeB, $nodeC->getPreviousSibling());
     $this->assertSame(null, $nodeC->getNextSibling());
     $nodeD = new Tag(array(), 'div', array());
     $node->addChild($nodeD);
     $this->assertSame($nodeB, $nodeC->getPreviousSibling());
     $this->assertSame($nodeD, $nodeC->getNextSibling());
     return compact('node', 'nodeB', 'nodeC', 'nodeD');
 }
예제 #3
0
파일: Printer.php 프로젝트: gunderjt/MtHaml
 public function leaveTag(Tag $node)
 {
     $this->undent()->write(')', $node->hasAttributes() || $node->hasChilds());
 }