Skip to content

Commit 792cb97

Browse files
committed
convert templates to Latte-like syntax [WIP]
1 parent f8cf8a9 commit 792cb97

File tree

70 files changed

+1804
-954
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1804
-954
lines changed

src/Tracy/Bar/Bar.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function renderLoader(DeferredContent $defer): void
6363
$requestId = $defer->getRequestId();
6464
$nonceAttr = Helpers::getNonceAttr();
6565
$async = true;
66-
require __DIR__ . '/assets/loader.phtml';
66+
require __DIR__ . '/dist/loader.phtml';
6767
}
6868

6969

@@ -106,7 +106,7 @@ public function render(DeferredContent $defer): void
106106
$nonceAttr = Helpers::getNonceAttr();
107107
$async = false;
108108
Debugger::removeOutputBuffers(false);
109-
require __DIR__ . '/assets/loader.phtml';
109+
require __DIR__ . '/dist/loader.phtml';
110110
}
111111
}
112112
}
@@ -118,10 +118,10 @@ private function renderPartial(string $type, string $suffix = ''): array
118118

119119
return [
120120
'bar' => Helpers::capture(function () use ($type, $panels) {
121-
require __DIR__ . '/assets/bar.phtml';
121+
require __DIR__ . '/dist/bar.phtml';
122122
}),
123123
'panels' => Helpers::capture(function () use ($type, $panels) {
124-
require __DIR__ . '/assets/panels.phtml';
124+
require __DIR__ . '/dist/panels.phtml';
125125
}),
126126
];
127127
}

src/Tracy/Bar/DefaultBarPanel.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function getTab(): string
3535
{
3636
return Helpers::capture(function () {
3737
$data = $this->data;
38-
require __DIR__ . "/panels/{$this->id}.tab.phtml";
38+
require __DIR__ . "/dist/{$this->id}.tab.phtml";
3939
});
4040
}
4141

@@ -46,9 +46,9 @@ public function getTab(): string
4646
public function getPanel(): string
4747
{
4848
return Helpers::capture(function () {
49-
if (is_file(__DIR__ . "/panels/{$this->id}.panel.phtml")) {
49+
if (is_file(__DIR__ . "/dist/{$this->id}.panel.phtml")) {
5050
$data = $this->data;
51-
require __DIR__ . "/panels/{$this->id}.panel.phtml";
51+
require __DIR__ . "/dist/{$this->id}.panel.phtml";
5252
}
5353
});
5454
}

src/Tracy/Bar/assets/bar.latte

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{*
2+
* @var string $type
3+
* @var \stdClass[] $panels
4+
*}
5+
6+
<ul class="tracy-row" data-tracy-group="{$type}">
7+
{if $type === main}
8+
<li id="tracy-debug-logo" title="Tracy Debugger {=Tracy\Debugger::Version}
9+
https://tracy.nette.org">
10+
<svg viewBox="0 -10 1561 333"><path fill="#585755" d="m176 327h-57v-269h-119v-57h291v57h-115v269zm208-191h114c50 0 47-78 0-78h-114v78zm106-135c17 0 33 2 46 7 75 30 75 144 1 175-13 6-29 8-47 8h-27l132 74v68l-211-128v122h-57v-326h163zm300 57c-5 0-9 3-11 9l-56 156h135l-55-155c-2-7-6-10-13-10zm-86 222l-17 47h-61l102-285c20-56 107-56 126 0l102 285h-61l-17-47h-174zm410 47c-98 0-148-55-148-163v-2c0-107 50-161 149-161h118v57h-133c-26 0-45 8-58 25-12 17-19 44-19 81 0 71 26 106 77 106h133v57h-119zm270-145l-121-181h68l81 130 81-130h68l-121 178v148h-56v-145z"/></svg>
11+
</li>
12+
{/if}
13+
14+
{if $type === redirect}
15+
<li><span title="Previous request before redirect">redirect</span></li>
16+
{/if}
17+
18+
{if $type === ajax}
19+
<li>AJAX</li>
20+
{/if}
21+
22+
{foreach $panels as $panel}
23+
{if $panel->tab}
24+
<li>{if $panel->panel}<a href="#" rel="tracy-debug-panel-{$panel->id}">{trim($panel->tab)}</a>
25+
{else}<span>{trim($panel->tab)}</span>
26+
{/if}</li>
27+
{/if}
28+
{/foreach}
29+
30+
{if $type === main}
31+
<li><a href="#" data-tracy-action="close" title="close debug bar">&times;</a></li>
32+
{/if}
33+
</ul>

src/Tracy/Bar/assets/bar.phtml

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/Tracy/Bar/assets/loader.latte

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{*
2+
* @var string $nonceAttr
3+
* @var bool $async
4+
* @var string $requestId
5+
*}
6+
7+
{do $baseUrl = $_SERVER[REQUEST_URI] ?? ''}
8+
{do $baseUrl .= strpos($baseUrl, '?') === false ? '?' : '&'}
9+
{do $asyncAttr = $async ? ' async' : ''}
10+
11+
{if empty($content)}
12+
<script src="{$baseUrl}_tracy_bar={urlencode("content.{$requestId}")}&amp;XDEBUG_SESSION_STOP=1" data-id="{$requestId}"{$asyncAttr}{$nonceAttr}></script>
13+
{else}
14+
15+
<!-- Tracy Debug Bar -->
16+
<script src="{$baseUrl}_tracy_bar=js&amp;v={urlencode(Tracy\Debugger::Version)}&amp;XDEBUG_SESSION_STOP=1" data-id="{$requestId}"{$nonceAttr}></script>
17+
<script{$nonceAttr}>
18+
Tracy.Debug.init({str_replace(['<!--', '</s'], ['<\!--', '<\/s'], json_encode($content, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_SUBSTITUTE))});
19+
</script>
20+
{/if}

src/Tracy/Bar/assets/loader.phtml

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/Tracy/Bar/assets/panels.latte

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{*
2+
* @var string $type
3+
* @var \stdClass[] $panels
4+
*}
5+
{do $icons = '
6+
<div class="tracy-icons">
7+
<a href="#" data-tracy-action="window" title="open in window">&curren;</a>
8+
<a href="#" data-tracy-action="close" title="close window">&times;</a>
9+
</div>
10+
'}
11+
<div itemscope>
12+
{foreach $panels as $panel}
13+
{do $content = $panel->panel ? $panel->panel . "\n" . $icons : ''}
14+
{do $class = 'tracy-panel ' . ($type === ajax ? '' : tracy-panel-persist) . ' tracy-panel-' . $type}
15+
<div class="{$class}" id="tracy-debug-panel-{$panel->id}" data-tracy-content='{str_replace(['&', "'"], ['&amp;', '&#039;'], $content)}'></div>
16+
{/foreach}
17+
<meta itemprop=tracy-snapshot content={=Tracy\Dumper::formatSnapshotAttribute(Dumper::$liveSnapshot)}>
18+
</div>

src/Tracy/Bar/assets/panels.phtml

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/Tracy/Bar/dist/bar.phtml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
declare(strict_types=1);
3+
?>
4+
5+
<ul class="tracy-row" data-tracy-group="<?= Tracy\Helpers::escapeHtml($type) ?>
6+
">
7+
<?php if ($type === 'main'): ?> <li id="tracy-debug-logo" title="Tracy Debugger <?= Tracy\Helpers::escapeHtml(Tracy\Debugger::Version) ?>
8+
9+
https://tracy.nette.org">
10+
<svg viewBox="0 -10 1561 333"><path fill="#585755" d="m176 327h-57v-269h-119v-57h291v57h-115v269zm208-191h114c50 0 47-78 0-78h-114v78zm106-135c17 0 33 2 46 7 75 30 75 144 1 175-13 6-29 8-47 8h-27l132 74v68l-211-128v122h-57v-326h163zm300 57c-5 0-9 3-11 9l-56 156h135l-55-155c-2-7-6-10-13-10zm-86 222l-17 47h-61l102-285c20-56 107-56 126 0l102 285h-61l-17-47h-174zm410 47c-98 0-148-55-148-163v-2c0-107 50-161 149-161h118v57h-133c-26 0-45 8-58 25-12 17-19 44-19 81 0 71 26 106 77 106h133v57h-119zm270-145l-121-181h68l81 130 81-130h68l-121 178v148h-56v-145z"/></svg>
11+
</li>
12+
<?php endif ?>
13+
<?php if ($type === 'redirect'): ?> <li><span title="Previous request before redirect">redirect</span></li>
14+
<?php endif ?>
15+
<?php if ($type === 'ajax'): ?> <li>AJAX</li>
16+
<?php endif ?>
17+
<?php foreach ($panels as $panel): ?><?php if ($panel->tab): ?> <li><?php if ($panel->panel): ?>
18+
<a href="#" rel="tracy-debug-panel-<?= Tracy\Helpers::escapeHtml($panel->id) ?>
19+
"><?= Tracy\Helpers::escapeHtml(trim($panel->tab)) ?>
20+
</a>
21+
<?php else: ?>
22+
<span><?= Tracy\Helpers::escapeHtml(trim($panel->tab)) ?>
23+
</span>
24+
<?php endif ?>
25+
</li>
26+
<?php endif ?><?php endforeach ?>
27+
<?php if ($type === 'main'): ?> <li><a href="#" data-tracy-action="close" title="close debug bar">&times;</a></li>
28+
<?php endif ?></ul>
Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<?php
2-
32
declare(strict_types=1);
4-
5-
namespace Tracy;
6-
7-
/** @var array[] $data */
83
?>
94
<style class="tracy-debug">
105
#tracy-debug .tracy-DumpPanel h2 {
@@ -19,11 +14,9 @@ namespace Tracy;
1914
<h1>Dumps</h1>
2015

2116
<div class="tracy-inner tracy-DumpPanel">
22-
<?php foreach ($data as $item): ?>
23-
<?php if ($item['title']):?>
24-
<h2><?= Helpers::escapeHtml($item['title']) ?></h2>
25-
<?php endif ?>
17+
<?php foreach ($data as $item): ?><?php if ($item['title']): ?> <h2><?= Tracy\Helpers::escapeHtml($item['title']) ?>
18+
</h2>
19+
<?php endif ?>
20+
<?= Tracy\Helpers::escapeHtml($item['dump']) ?>
2621

27-
<?= $item['dump'] ?>
28-
<?php endforeach ?>
29-
</div>
22+
<?php endforeach ?></div>

0 commit comments

Comments
 (0)