Skip to content

Commit 26941e2

Browse files
committed
convert templates to Latte-like syntax
1 parent 05ed236 commit 26941e2

File tree

86 files changed

+2570
-1735
lines changed

Some content is hidden

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

86 files changed

+2570
-1735
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.gitignore export-ignore
44
ncs.* export-ignore
55
phpstan*.neon export-ignore
6+
src/**/*.latte export-ignore
67
tests/ export-ignore
78

89
*.php* diff=php

.github/workflows/coding-style.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
coverage: none
1515

1616
- run: composer create-project nette/code-checker temp/code-checker ^3 --no-progress
17-
- run: php temp/code-checker/code-checker --strict-types --no-progress -i tests/Tracy/fixtures -i examples/assets
17+
- run: php temp/code-checker/code-checker --strict-types --no-progress -i tests/Tracy/fixtures -i examples/assets -i *.latte
1818

1919

2020
nette_cs:

phpstan.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,9 @@ parameters:
7272
-
7373
identifier: missingType.return
7474
path: src/Tracy/Logger/ILogger.php
75+
76+
# Arrow function callback receives class names from get_declared_classes() etc.
77+
-
78+
identifier: argument.type
79+
message: '#class\-string#'
80+
path: src/Tracy/Bar/panels/info.panel.php

src/Tracy/Bar/Bar.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ public function renderLoader(DeferredContent $defer): void
6060

6161
$this->loaderRendered = true;
6262
$requestId = $defer->getRequestId();
63-
$nonceAttr = Helpers::getNonceAttr();
6463
$async = true;
65-
require __DIR__ . '/assets/loader.phtml';
64+
require __DIR__ . '/dist/loader.phtml';
6665
}
6766

6867

@@ -102,10 +101,9 @@ public function render(DeferredContent $defer): void
102101
$defer->addSetup('Tracy.Debug.init', $content);
103102

104103
} else {
105-
$nonceAttr = Helpers::getNonceAttr();
106104
$async = false;
107105
Debugger::removeOutputBuffers(errorOccurred: false);
108-
require __DIR__ . '/assets/loader.phtml';
106+
require __DIR__ . '/dist/loader.phtml';
109107
}
110108
}
111109
}
@@ -118,10 +116,10 @@ private function renderPartial(string $type, string $suffix = ''): array
118116

119117
return [
120118
'bar' => Helpers::capture(function () use ($type, $panels) {
121-
require __DIR__ . '/assets/bar.phtml';
119+
require __DIR__ . '/dist/bar.phtml';
122120
}),
123121
'panels' => Helpers::capture(function () use ($type, $panels) {
124-
require __DIR__ . '/assets/panels.phtml';
122+
require __DIR__ . '/dist/panels.phtml';
125123
}),
126124
];
127125
}

src/Tracy/Bar/DefaultBarPanel.php

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

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

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)|noescape}</a>
25+
{else}<span>{trim($panel->tab)|noescape}</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: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{*
2+
* @var bool $async
3+
* @var string $requestId
4+
*}
5+
6+
{do $nonce = Tracy\Helpers::getNonce()}
7+
{do $baseUrl = $_SERVER['REQUEST_URI'] ?? ''}
8+
{do $baseUrl .= strpos($baseUrl, '?') === false ? '?' : '&'}
9+
10+
{if empty($content)}
11+
<script src="{$baseUrl}_tracy_bar={urlencode('content.' . $requestId)}&amp;XDEBUG_SESSION_STOP=1" data-id="{$requestId}" async={$async} nonce={$nonce}></script>
12+
{else}
13+
14+
15+
16+
17+
<!-- Tracy Debug Bar -->
18+
<script src="{$baseUrl}_tracy_bar=js&amp;v={urlencode(Tracy\Debugger::Version)}&amp;XDEBUG_SESSION_STOP=1" data-id="{$requestId}" nonce={$nonce}></script>
19+
<script nonce={$nonce}>
20+
Tracy.Debug.init({str_replace(['<!--', '</s'], ['<\!--', '<\/s'], json_encode($content, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_INVALID_UTF8_SUBSTITUTE))|noescape});
21+
</script>
22+
{/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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{*
2+
* @var string $type
3+
* @var stdClass[] $panels
4+
*}
5+
{use Tracy\Dumper}
6+
7+
{do $icons = '
8+
<div class="tracy-icons">
9+
<a href="#" data-tracy-action="window" title="open in window">&curren;</a>
10+
<a href="#" data-tracy-action="close" title="close window">&times;</a>
11+
</div>
12+
'}
13+
<div itemscope>
14+
{foreach $panels as $panel}
15+
{do $content = $panel->panel ? $panel->panel . "\n" . $icons : ''}
16+
<div class={[tracy-panel, $type !== ajax ? tracy-panel-persist : null, 'tracy-panel-' . $type]} id="tracy-debug-panel-{$panel->id}" data-tracy-content='{str_replace(['&', "'"], ['&amp;', '&#039;'], $content)|noescape}'></div>
17+
{/foreach}
18+
<meta itemprop=tracy-snapshot content={=Dumper::formatSnapshotAttribute(Dumper::$liveSnapshot)}>
19+
</div>

0 commit comments

Comments
 (0)