Skip to content

Instantly share code, notes, and snippets.

@theseer
Created August 6, 2019 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theseer/3962ae28b446c6f4fae0ec2bd476a221 to your computer and use it in GitHub Desktop.
Save theseer/3962ae28b446c6f4fae0ec2bd476a221 to your computer and use it in GitHub Desktop.
<?php declare(strict_types = 1);
namespace test;
use DOMDocument;
use Templado\Engine\SimpleSnippet;
use Templado\Engine\SnippetListCollection;
use Templado\Engine\Templado;
require __DIR__ . '/vendor/autoload.php';
$codeBlock = new DOMDocument();
$element = $codeBlock->createElement('h1', 'This Is A Simple Snippet Example');
// If you enable the following line, the h1 element in the document will get replaced,
// otherwise this h1 will become a child of the h1 of the document
//$element->setAttribute('id', 'header');
$snippet = new SimpleSnippet('header', $element);
$html = Templado::parseHtmlString('<?xml version="1.0" ?><html><h1 id="header" /></html>');
$collection = new SnippetListCollection();
$collection->addSnippet($snippet);
$html->applySnippets($collection);
echo $html->asString();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment