From 875505b9364c241d055bac3c2c248d63c5ef4eca Mon Sep 17 00:00:00 2001 From: Mychi Darko Date: Mon, 24 May 2021 07:46:40 +0000 Subject: [PATCH] :sparkles: added experimental view features --- Config/aloe.php | 18 ------------------ Config/functions.php | 6 +++--- Config/view.php | 23 ++++++++--------------- 3 files changed, 11 insertions(+), 36 deletions(-) delete mode 100644 Config/aloe.php diff --git a/Config/aloe.php b/Config/aloe.php deleted file mode 100644 index e8a094c..0000000 --- a/Config/aloe.php +++ /dev/null @@ -1,18 +0,0 @@ - [ - "controllers_path" => "/Controllers", - "models_path" => "/Models", - "migrations_path" => "/Migrations", - "seeds_path" => "/Seeds", - "factories_path" => "/Factories", - "helpers_path" => "/Helpers", - "views_path" => "/pages", - "config_path" => "/Config", - "storage_path" => "/storage", - "commands_path" => "/Console", - "routes_path" => "/routes", - "lib_path" => "/Lib", - ], -]; diff --git a/Config/functions.php b/Config/functions.php index 7ac8f4a..5d628b0 100644 --- a/Config/functions.php +++ b/Config/functions.php @@ -159,9 +159,9 @@ function plural($value, $count = 2) if (!function_exists('render')) { function render(string $view, array $data = []) { - if (viewConfig("view_engine") === \Leaf\Blade::class) { - return markup(view($view, $data)); - } + if (!viewConfig("experimental")) { + return markup(view($view, $data)); + } return viewConfig("render")($view, $data); } diff --git a/Config/view.php b/Config/view.php index 6379f44..641f38b 100644 --- a/Config/view.php +++ b/Config/view.php @@ -27,33 +27,26 @@ /* |-------------------------------------------------------------------------- - | Template Engine [EXPERIMENTAL] + | Leaf EXPERIMENTAL features |-------------------------------------------------------------------------- | - | Leaf MVC unlike other frameworks tries to give you as much control as - | you need. As such, you can decide which view engine to use. + | This allows you to use the experimental features below | */ - "view_engine" => \Leaf\Blade::class, + "experimental" => false, /* |-------------------------------------------------------------------------- | Custom render method [EXPERIMENTAL] |-------------------------------------------------------------------------- | - | This render method is triggered whenever render() is called - | in your app if you're using a custom view engine. + | This render method is triggered whenever render() with the experimental + | option above set to true. This render method allows you to even plug + | in external view libraries, configure them and call them with `render` + | whenever and wherever you feel the need. | */ "render" => function(string $view, array $data = []) { - $veins = new \Leaf\Veins\Template; - $veins->configure([ - "veins_dir" => views_path(null, false), - "cache_dir" => storage_path('framework/views/'), - ]); - $veins->set($data); - $veins->render($view); - - // This example is what veins would look like + return markup(view($view, $data)); }, ];