Skip to content

Commit

Permalink
Add appendTemplate() helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
g105b committed Feb 21, 2015
1 parent 2cc19fd commit 4fb69bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/Dom/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public function __set($name, $value) {
$this->setValue($value);
break;

case "templateName":
case "templateParentNode":
case "templatePreviousSibling":
case "templateNextSibling":
Expand Down Expand Up @@ -204,10 +205,16 @@ public function __call($name, $args) {
return $value;
}

// TODO: attach template parent stuff...
if($name === "appendTemplate"
&& !empty($this->domNode->templateName)) {
$this->templateParentNode->insertBefore(
$this,
$this->templateNextSibling
);
return;
}

throw new NodeMethodNotDefinedException($name);
break;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Page/TemplateFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ public function __construct($document) {
public function get($name) {
if(isset($this->elementArray[$name])) {
$node = $this->elementArray[$name]->cloneNode(true);
$node->templateName = $name;
$node->templateParentNode = $this->templateNodeMap["parent"][$name];
$node->templatePreviousSibling =
$this->templateNodeMap["previousSibling"][$name];
$node->templateNextSibling =
$this->templateNodeMap["nextSibling"][$name];
$node->template = $name;

return $node;
}

Expand Down

0 comments on commit 4fb69bf

Please sign in to comment.