Created
August 6, 2019 21:54
-
-
Save theseer/3962ae28b446c6f4fae0ec2bd476a221 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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