Skip to content

Commit 4fe4867

Browse files
committed
feat: automatically configure view engine if not in MVC
1 parent b3c55f3 commit 4fe4867

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/Config.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,23 @@ public static function attachView($className, $name = null)
6262
$class = new $className();
6363
$diIndex = $name ?? static::getDiIndex($class);
6464

65+
if (!class_exists('Leaf\Core') && !static::getStatic('views.path') && is_dir('views')) {
66+
app()->vite();
67+
app()->config([
68+
'views.path' => 'views',
69+
'views.cache' => 'cache'
70+
]);
71+
72+
if ($className === 'Leaf\Blade') {
73+
$class->configure([
74+
'views' => 'views',
75+
'cache' => 'cache'
76+
]);
77+
} else if ($className === 'Leaf\BareUI') {
78+
$class->config('path', './views');
79+
}
80+
}
81+
6582
static::set("views.$diIndex", $class);
6683
}
6784

0 commit comments

Comments
 (0)