Skip to content

Commit

Permalink
LattePanel: removed dependency on Nette [Closes #274]
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Aug 8, 2021
1 parent f5ceb70 commit 1576c49
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
7 changes: 2 additions & 5 deletions src/Bridges/Tracy/LattePanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

use Latte\Engine;
use Latte\Runtime\Template;
use Nette;
use Tracy;


Expand All @@ -20,8 +19,6 @@
*/
class LattePanel implements Tracy\IBarPanel
{
use Nette\SmartObject;

/** @var bool */
public $dumpParameters = true;

Expand Down Expand Up @@ -60,7 +57,7 @@ public function getTab(): ?string
return null;
}

return Nette\Utils\Helpers::capture(function () {
return Tracy\Helpers::capture(function () {
$name = $this->name ?? basename(reset($this->templates)->getName());
require __DIR__ . '/templates/LattePanel.tab.phtml';
});
Expand All @@ -75,7 +72,7 @@ public function getPanel(): string
$this->list = [];
$this->buildList($this->templates[0]);

return Nette\Utils\Helpers::capture(function () {
return Tracy\Helpers::capture(function () {
$list = $this->list;
$dumpParameters = $this->dumpParameters;
require __DIR__ . '/templates/LattePanel.panel.phtml';
Expand Down
24 changes: 12 additions & 12 deletions src/Bridges/Tracy/templates/LattePanel.panel.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ $colors = [
?>

<style class="tracy-debug">
#tracy-debug .nette-LattePanel td {
#tracy-debug .LattePanel td {
white-space: nowrap;
}

#tracy-debug .nette-LattePanel-php {
#tracy-debug .LattePanel-php {
background: #8993be;
color: white;
border-radius: 79px;
Expand All @@ -36,51 +36,51 @@ $colors = [
margin-left: 2ex;
}

#tracy-debug .nette-LattePanel-type {
#tracy-debug .LattePanel-type {
border-radius: 2px;
padding: 2px 4px;
font-size: 80%;
color: white;
font-weight: bold;
}

#tracy-debug .nette-LattePanel-include {
#tracy-debug .LattePanel-include {
background: #00000052;
}

#tracy-debug .nette-LattePanel-extends {
#tracy-debug .LattePanel-extends {
background: #cd1c1c7d;
}

#tracy-debug .nette-LattePanel-import,
#tracy-debug .nette-LattePanel-includeblock {
#tracy-debug .LattePanel-import,
#tracy-debug .LattePanel-includeblock {
background: #17c35b8f;
}

#tracy-debug .nette-LattePanel-embed {
#tracy-debug .LattePanel-embed {
background: #4f1ccd7d;
}

#tracy-debug .nette-LattePanel-sandbox {
#tracy-debug .LattePanel-sandbox {
background: black;
}
</style>

<h1>Rendered Templates</h1>

<div class="tracy-inner nette-LattePanel">
<div class="tracy-inner LattePanel">
<table>
<?php foreach ($list as $item): ?>
<tr>
<td>
<?php if ($item->template->getReferenceType()): ?>
<span style="margin-left: <?= $item->depth * 4 ?>ex"></span>└ 
<span class="nette-LattePanel-type" style="background: <?= $colors[$item->template->getReferenceType()] ?>"><?= Helpers::escapeHtml($item->template->getReferenceType()) ?></span>
<span class="LattePanel-type" style="background: <?= $colors[$item->template->getReferenceType()] ?>"><?= Helpers::escapeHtml($item->template->getReferenceType()) ?></span>
<?php endif ?>

<?= Helpers::editorLink($item->template->getName()) ?>

<a href="<?= Helpers::escapeHtml(Helpers::editorUri($item->phpFile)) ?>" class="nette-LattePanel-php">php</a>
<a href="<?= Helpers::escapeHtml(Helpers::editorUri($item->phpFile)) ?>" class="LattePanel-php">php</a>
</td>

<td><?= $item->count > 1 ? $item->count . '×' : '' ?></td>
Expand Down

0 comments on commit 1576c49

Please sign in to comment.