/**
  * Parses the specified template library
  *
  * @param string $tagName
  * @param DOMNode $node
  */
 private function parseLibrary($tagName, DOMNode &$node)
 {
     // Set the My context based on the node's attributes
     $myContext = $this->nodeAttributesToScope($node);
     // Template call has child nodes, those are params that can be used in a os:Render call, store them
     $oldNodeContext = isset($this->dataContext['_os_render_nodes']) ? $this->dataContext['_os_render_nodes'] : array();
     $this->dataContext['_os_render_nodes'] = array();
     if ($node->childNodes->length) {
         foreach ($node->childNodes as $childNode) {
             if (isset($childNode->tagName) && !empty($childNode->tagName)) {
                 $nodeParam = ($pos = strpos($childNode->tagName, ':')) ? trim(substr($childNode->tagName, $pos + 1)) : trim($childNode->tagName);
                 $this->dataContext['_os_render_nodes'][$nodeParam] = $childNode;
                 $myContext[$nodeParam] = $this->nodeAttributesToScope($childNode);
             }
         }
     }
     // Parse the template library (store the My scope since this could be a nested call)
     $previousMy = $this->dataContext['My'];
     $this->dataContext['My'] = $myContext;
     $ret = $this->templateLibrary->parseTemplate($tagName, $this);
     $this->dataContext['My'] = $previousMy;
     $this->dataContext['_os_render_nodes'] = $oldNodeContext;
     if ($ret) {
         // And replace the node with the parsed output
         $ownerDocument = $node->ownerDocument;
         foreach ($ret->childNodes as $childNode) {
             $importedNode = $ownerDocument->importNode($childNode, true);
             $importedNode = $node->parentNode->insertBefore($importedNode, $node);
         }
     }
 }