Ejemplo n.º 1
0
 public function active(IObject $aParent, string $aSource, &$nPosition)
 {
     $nLine = ObjectBase::getLine($aSource, $nPosition);
     $nStartPos = $nPosition;
     // 标签名称
     if (!($sTagName = $this->parseTagName($aSource, $nPosition))) {
         throw new Exception("UI引擎在分析模板时遇到无效的xhtml节点:缺少节点名称(位置:%d行)", $nLine);
     }
     $aTag = new Tag($sTagName, null, 0, $nStartPos, 0, $nLine, '');
     // 尾标签
     if ($sTagName[0] == '/') {
         if (!$aParent instanceof Node) {
             throw new Exception("错误类型");
         }
         $aTag->setTagType(Tag::TYPE_TAIL);
         $aTag->setName(substr($sTagName, 1));
         $aParent->setTailTag($aTag);
     } else {
         $aTag->setTagType(Tag::TYPE_HEAD);
         $aNode = new Node($aTag);
         $aParent->add($aNode);
     }
     return $aTag;
 }