-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
37 lines (28 loc) · 858 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
use Kirby\Cms\App as Kirby;
use Kirby\Cms\Template;
class TidyHTML extends Template {
public function render(array $data = []): string {
$kirby = Kirby::instance();
$html = parent::render($data);
if ($kirby->option('dgsiegel.kirby-tidy-html.enabled') === true && $this->hasDefaultType() === true) {
$options = $kirby->option('dgsiegel.kirby-tidy-html.options', []);
$tidy = new tidy();
$tidy->parseString($html, $options);
$tidy->cleanRepair();
return $tidy;
}
return $html;
}
}
Kirby::plugin('dgsiegel/kirby-tidy-html', [
'options' => [
'enabled' => false,
'options' => []
],
'components' => [
'template' => function (Kirby $kirby, string $name, string $type = 'html', string $defaultType = 'html') {
return new TidyHTML($name, $type, $defaultType);
}
]
]);