From 48df7d1e471a2f444f61d6b093110da8e8800ba4 Mon Sep 17 00:00:00 2001 From: caiyuzheng <290198252@qq.com> Date: Wed, 21 Aug 2019 15:34:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E6=B8=B2=E6=9F=93=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Controllers/Home.php | 2 +- App/Views/Home/index.html | 2 +- App/Views/base.html | 1 + Core/View.php | 6 ------ 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/App/Controllers/Home.php b/App/Controllers/Home.php index b8ad65a..d28be53 100644 --- a/App/Controllers/Home.php +++ b/App/Controllers/Home.php @@ -31,7 +31,7 @@ class Home extends \Core\Controller } public function renderAction() { - + View::renderTemplate("/Home/index.html",[]); } public function docsAction(){ $docs = new Models\Doc(); diff --git a/App/Views/Home/index.html b/App/Views/Home/index.html index cbe8ca0..0c21beb 100644 --- a/App/Views/Home/index.html +++ b/App/Views/Home/index.html @@ -4,6 +4,6 @@ {% block body %} -
dfsd
+
this is a title
{% endblock %} diff --git a/App/Views/base.html b/App/Views/base.html index 08e2e58..cc03852 100644 --- a/App/Views/base.html +++ b/App/Views/base.html @@ -5,6 +5,7 @@ {% block title %}{% endblock %} + shit! {% block body %} {% endblock %} diff --git a/Core/View.php b/Core/View.php index 2da0127..5f4c716 100644 --- a/Core/View.php +++ b/Core/View.php @@ -9,7 +9,6 @@ namespace Core; */ class View { - /** * Render a view file * @@ -21,16 +20,13 @@ class View public static function render($view, $args = []) { extract($args, EXTR_SKIP); - $file = dirname(__DIR__) . "/App/Views/$view"; // relative to Core directory - if (is_readable($file)) { require $file; } else { throw new \Exception("$file not found"); } } - /** * Render a view template using Twig * @@ -42,12 +38,10 @@ class View public static function renderTemplate($template, $args = []) { static $twig = null; - if ($twig === null) { $loader = new \Twig_Loader_Filesystem(dirname(__DIR__) . '/App/Views'); $twig = new \Twig_Environment($loader); } - echo $twig->render($template, $args); } }