Skip to content

Commit

Permalink
Refactoring to use TemplateTask
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed May 30, 2009
1 parent f1821f5 commit fb2be78
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions cake/console/libs/tasks/view.php
Expand Up @@ -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
*
Expand Down Expand Up @@ -175,6 +175,7 @@ function all() {
}
}
}

/**
* Handles interactive baking
*
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit fb2be78

Please sign in to comment.