ENHANCEMENT Added Controller->render($params) as a shortcut for Controller->customise($params)->renderWith(array('MyTemplate','MySubTemplate')) - templates are auto-detected by Controller->getViewer() and Controller->getAction()

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63652 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-10-05 19:27:21 +00:00
parent e1e2329c90
commit d53bbb0df1

View File

@ -248,6 +248,24 @@ class Controller extends RequestHandlingData {
}
return new SSViewer($templates);
}
/**
* Render the current controller with the templates determined
* by {@link getViewer()}.
*
* @param array $params Key-value array for custom template variables (Optional)
* @return string Parsed template content
*/
function render($params = null) {
$template = $this->getViewer($this->getAction());
// if the object is already customised (e.g. through Controller->run()), use it
$obj = ($this->customisedObj) ? $this->customisedObj : $this;
if($params) $obj = $this->customise($params);
return $template->process($obj);
}
/**
* Call this to disable basic authentication on test sites.