Skip to content
This repository has been archived by the owner on Mar 29, 2021. It is now read-only.

Commit

Permalink
Separate entities into own class and add fetch option
Browse files Browse the repository at this point in the history
  • Loading branch information
hxtree committed Feb 4, 2020
1 parent f46af97 commit 79170ea
Show file tree
Hide file tree
Showing 3 changed files with 1,784 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ It instantiates DomElements as customizable backend components and orchestrates
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/hxtree)

LHTML5
```
```PHP
<?php require $_SERVER['DOCUMENT_ROOT'] . '/src/Autoloader.php'; ?>
<body>
<partial name="userprofile">
Expand Down
28 changes: 3 additions & 25 deletions src/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use DomDocument;
use DOMElement;
use DOMXPath;
use Masterminds\HTML5;

/**
* Class Engine
Expand Down Expand Up @@ -46,15 +45,6 @@ class Engine
'css' => []
];

// entities are required to avoid server side DOM parse errors
public $entities = [
'nbsp' => '&#160;',
'copy' => '&#169;',
'reg' => '&#174;',
'trade' => '&#8482;',
'mdash' => '&#8212;'
];

// Component placeholder ID attribute
private $element_index_attribute = '_livingMarkup_ref';

Expand Down Expand Up @@ -103,11 +93,9 @@ public function __construct(array $parameters)
*/
public function setDoctype(): void
{
$entity = '';
foreach ($this->entities as $key => $value) {
$entity .= '<!ENTITY ' . $key . ' "' . $value . '">' . PHP_EOL;
}

$entities = new Entities;
$entity = $entities->get();
$this->doctype = '<!DOCTYPE html [' . $entity . ']> ';
}

Expand Down Expand Up @@ -442,16 +430,6 @@ private function getDomElementArgs(DOMElement &$element): array
*/
public function __toString(): string
{

// TODO: consider whether to keep HTML5 mastermind
$source = $this->dom->saveHTML();

$html5 = new HTML5([
'disable_html_ns' => true
]);
$dom = $html5->loadHTML($source);

return $html5->saveHTML($dom);

return $this->dom->saveHTML();
}
}
Loading

0 comments on commit 79170ea

Please sign in to comment.