forked from afbora/kirby-blade
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.php
46 lines (43 loc) · 1.43 KB
/
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
38
39
40
41
42
43
44
45
46
<?php
use Kirby\Cms\App as Kirby;
use Kirby\Template\Snippet as KirbySnippet;
use Leitsch\Blade\BladeDirectives;
use Leitsch\Blade\BladeFactory;
use Leitsch\Blade\BladeIfStatements;
use Leitsch\Blade\Paths;
use Leitsch\Blade\Snippet;
use Leitsch\Blade\Template;
@include_once __DIR__.'/vendor/autoload.php';
Kirby::plugin('leitsch/blade', [
'options' => [
'views' => function () {
return kirby()->roots()->cache().'/views';
},
'directives' => [],
'ifs' => [],
],
'components' => [
'template' => function (Kirby $kirby, string $name, ?string $contentType = null, ?string $defaultType = 'html') {
return new Template($kirby, $name, $contentType, $defaultType);
},
'snippet' => function (Kirby $kirby, ?string $name, array $data = [], bool $slots = false): KirbySnippet|string {
return (new Snippet($kirby, $name, $data, $slots))->load();
},
],
'hooks' => [
'system.loadPlugins:after' => function () {
BladeFactory::register([Paths::getPathTemplates()], Paths::getPathViews());
BladeDirectives::register();
BladeIfStatements::register();
},
],
'routes' => [
[
// Block all requests to /url.blade and return 404
'pattern' => '(:all)\.blade',
'action' => function ($all) {
return false;
},
],
],
]);