Goetas\Twital\Compiler::createControlNode PHP Method

createControlNode() public method

public createControlNode ( string $content ) : DOMCDATASection
$content string
return DOMCDATASection
    public function createControlNode($content)
    {
        $printPart = $this->getLexerOption('tag_block');
        return $this->document->createCDATASection("__[__{$printPart[0]} " . $content . " {$printPart[1]}__]__");
    }

Usage Example

Exemplo n.º 1
0
 public function visit(\DOMElement $node, Compiler $context)
 {
     if ($node->hasAttribute("from-exp")) {
         $filename = $node->getAttribute("from-exp");
     } elseif ($node->hasAttribute("from")) {
         $filename = '"' . $node->getAttribute("from") . '"';
     } else {
         throw new Exception("The 'from' or 'from-exp' attribute is required");
     }
     // remove any non-element node
     foreach (iterator_to_array($node->childNodes) as $child) {
         if (!$child instanceof \DOMElement) {
             $child->parentNode->removeChild($child);
         }
     }
     $context->compileChilds($node);
     $code = "embed {$filename}";
     if ($node->hasAttribute("ignore-missing") && $node->hasAttribute("ignore-missing") !== false) {
         $code .= " ignore missing";
     }
     if ($node->hasAttribute("with")) {
         $code .= " with " . $node->getAttribute("with");
     }
     if ($node->hasAttribute("only") && $node->getAttribute("only") !== "false") {
         $code .= " only";
     }
     $ext = $context->createControlNode($code);
     $set = iterator_to_array($node->childNodes);
     $n = $node->ownerDocument->createTextNode("\n");
     array_unshift($set, $n);
     array_unshift($set, $ext);
     $set[] = $context->createControlNode("endembed");
     DOMHelper::replaceWithSet($node, $set);
 }
All Usage Examples Of Goetas\Twital\Compiler::createControlNode