Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <?php declare(strict_types = 1);
  2. namespace test;
  3.  
  4. use DOMDocument;
  5. use Templado\Engine\SimpleSnippet;
  6. use Templado\Engine\SnippetListCollection;
  7. use Templado\Engine\Templado;
  8.  
  9. require __DIR__ . '/vendor/autoload.php';
  10.  
  11. $codeBlock = new DOMDocument();
  12. $element = $codeBlock->createElement('h1', 'This Is A Simple Snippet Example');
  13.  
  14. // If you enable the following line, the h1 element in the document will get replaced,
  15. // otherwise this h1 will become a child of the h1 of the document
  16. //$element->setAttribute('id', 'header');
  17.  
  18. $snippet = new SimpleSnippet('header', $element);
  19.  
  20. $html = Templado::parseHtmlString('<?xml version="1.0" ?><html><h1 id="header" /></html>');
  21.  
  22. $collection = new SnippetListCollection();
  23. $collection->addSnippet($snippet);
  24. $html->applySnippets($collection);
  25.  
  26.  
  27. echo $html->asString();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement