From fb2be781f2f513db8594e621597966a88164a198 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 30 May 2009 00:32:57 -0400 Subject: [PATCH] Refactoring to use TemplateTask --- cake/console/libs/tasks/view.php | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/cake/console/libs/tasks/view.php b/cake/console/libs/tasks/view.php index b85dac809f1..054dd978b98 100644 --- a/cake/console/libs/tasks/view.php +++ b/cake/console/libs/tasks/view.php @@ -45,7 +45,7 @@ class ViewTask extends Shell { * @var array * @access public */ - var $tasks = array('Project', 'Controller'); + var $tasks = array('Project', 'Controller', 'Template'); /** * path to VIEWS directory * @@ -175,6 +175,7 @@ function all() { } } } + /** * Handles interactive baking * @@ -353,29 +354,21 @@ function getContent($template = null, $vars = null) { $action = $template; $template = 'form'; } - $loaded = false; - foreach ($this->Dispatch->shellPaths as $path) { - $templatePath = $path . 'templates' . DS . 'views' . DS .Inflector::underscore($template).'.ctp'; - if (file_exists($templatePath) && is_file($templatePath)) { - $loaded = true; - break; - } - } if (!$vars) { $vars = $this->__loadController(); } - if ($loaded) { - extract($vars); - ob_start(); - ob_implicit_flush(0); - include($templatePath); - $content = ob_get_clean(); - return $content; + + $this->Template->set($vars); + $output = $this->Template->generate('views', $template); + + if (!empty($output)) { + return $output; } $this->hr(); $this->err(sprintf(__('Template for %s could not be found', true), $template)); return false; } + /** * Displays help contents *