示例#1
0
 protected function directiveTemplate($directive, Element $element, DOMNode $node, Scope $scope)
 {
     if (isset($directive['templateUrl'])) {
         $tpl = new Tpl($this->parent);
         $tpl->setScope($scope);
         $tpl->setDirectives($this->directives);
         $tpl->setFilters($this->filters);
         // $tpl->processNode($element->node);
         $newNode = $node->ownerDocument->importNode($element->node, true);
         $newChild = $node->parentNode->replaceChild($newNode, $node);
     }
 }
示例#2
0
         // var_dump($value);
         if ($value == '') {
             $value = $scope->properties;
         }
         $items = new DOMDocument();
         $frag = $items->createDocumentFragment();
         if (is_array($value) || $value instanceof Iterator || $value instanceof stdClass) {
             $length = $value instanceof Iterator ? $value->length : count($value);
             $repeatInfo = new RepeatInfo($length, $repkeys[0]);
             foreach ($value as $index => $item) {
                 if (!is_array($item) || $item instanceof Iterator) {
                     $item = [$item];
                 }
                 $doc = new DOMDocument();
                 $doc->appendChild($doc->importNode($element->node, true));
                 $tpl = new Tpl($attr->tpl->getParent());
                 $tpl->setIndex($index);
                 $tpl->setRepeatInfo($repeatInfo);
                 $tpl->setScope(new Scope($item, $scope));
                 $tpl->setDirectives($attr->tpl->getDirectives());
                 $tpl->setFilters($attr->tpl->getFilters());
                 $tpl->processNode($doc->documentElement);
                 $doc->documentElement->removeAttribute('repeat');
                 $frag->appendChild($items->importNode($doc->documentElement, true));
             }
         }
         $element->node->parentNode->replaceChild($element->node->ownerDocument->importNode($frag, true), $element->node);
     }];
 });
 /**
  * uses text as a sperator