(Yaf >=1.0.0)
Yaf_Controller_Abstract::render — 渲染视图模板
$tpl, ?array $parameters = ?): string|bool|null
渲染视图脚本 tpl 并返回其输出,这点与
Yaf_Controller_Abstract::display() 不同。
tpl视图脚本名,相对于视图路径。
parameters本次渲染要导出到视图脚本的变量关联数组。
示例 #1 Yaf_Controller_Abstract::render() 示例
<?php
class ProductController extends Yaf_Controller_Abstract
{
public function indexAction() {
// 不自动渲染默认模板
Yaf_Dispatcher::getInstance()->disableView();
// 渲染 product/index.phtml 并返回输出,
// 而不是像 display() 那样直接发送
$html = $this->render("product/index.phtml", array(
"products" => array("yaf", "php"),
));
// 后处理后设置为响应主体
$this->getResponse()->setBody($html);
}
}
?>