From 1e3188479a88e1b3b488d44fe8a482c573eda455 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 8 Aug 2011 14:33:53 -0500 Subject: [PATCH] Refactor the view class. --- system/view.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/system/view.php b/system/view.php index e1d7c9a5..20cf26cb 100644 --- a/system/view.php +++ b/system/view.php @@ -194,10 +194,7 @@ class View { throw new \Exception("View [$view] does not exist."); } - foreach ($this->data as &$data) - { - if ($data instanceof View or $data instanceof Response) $data = (string) $data; - } + $this->get_sub_views(); extract($this->data, EXTR_SKIP); @@ -208,6 +205,22 @@ class View { return ob_get_clean(); } + /** + * Evaluate the content of all bound sub-views and responses. + * + * @return void + */ + private function get_sub_views() + { + foreach ($this->data as &$data) + { + if ($data instanceof View or $data instanceof Response) + { + $data = (string) $data; + } + } + } + /** * Add a view instance to the view data. *