forked from Cryden/oc-htmlminify-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.php
34 lines (29 loc) · 1.04 KB
/
Plugin.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
<?php
namespace DmitryBykov\Htmlminify;
use nochso\HtmlCompressTwig\Extension;
use Event;
class Plugin extends \System\Classes\PluginBase
{
public function pluginDetails()
{
return [
'name' => 'HTML minify Plugin',
'description' => 'Any HTML, inline CSS and Javascript will be compressed.',
'author' => 'Dmitry Bykov',
'icon' => 'icon-compress',
'iconSVG' => 'plugins/DmitryBykov/htmlminify/assets/images/logo.png',
'homepage' => 'https://github.com/Cryden/oc-htmlminify-plugin'
];
}
public function boot()
{
// Event::listen('cms.page.beforeRenderPage', function($controller, $page) {
// $twig = $controller->getTwig();
// $twig->addExtension(new Extension(true));
// });
Event::listen('cms.page.display', function($controller, $path, $page, $content) {
$htmlcompress = new Extension(true);
return $htmlcompress->compress($controller->getTwig(), $content);
}, 10);
}
}