-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: bind placeholders using regex for #385 * fix: bind keyless placeholders using new method fixes #385 * maintenance: remove unused class * maintenance: remove commented out code * maintenance: remove unused variable
- Loading branch information
Showing
5 changed files
with
72 additions
and
105 deletions.
There are no files selected for viewing
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
use Gt\Dom\HTMLDocument; | ||
use Gt\DomTemplate\ListBinder; | ||
use Gt\DomTemplate\TemplateCollection; | ||
use Gt\DomTemplate\TemplateElement; | ||
|
||
require "vendor/autoload.php"; | ||
|
||
$html = <<<HTML | ||
<!doctype html> | ||
<ul> | ||
<li data-template> | ||
<a href="/orders/{{userId}}/{{username??defaultUser}}/">view</a> | ||
</li> | ||
</ul> | ||
HTML; | ||
|
||
$kvpList = [ | ||
(object)["userId" => 543, "username" => "win95", "orderCount" => 55], | ||
(object)["userId" => 559, "username" => "seafoam", "orderCount" => 30], | ||
(object)["userId" => 274, "username" => "hammatime", "orderCount" => 23], | ||
]; | ||
|
||
$string = ""; | ||
for($iteration = 0; $iteration < 1000; $iteration++) { | ||
$document = new HTMLDocument($html); | ||
$orderList = $document->querySelector("ul"); | ||
|
||
$templateElement = new TemplateElement($document->querySelector("ul li[data-template]")); | ||
$templateCollection = new TemplateCollection($document); | ||
$templateElement->removeOriginalElement(); | ||
|
||
$sut = new ListBinder($templateCollection); | ||
$sut->bindListData($kvpList, $orderList); | ||
$string .= $document; | ||
echo memory_get_usage(), PHP_EOL; | ||
} | ||
|
||
echo $document; |
This file contains 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
This file contains 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