public renderViewFile ( string $_viewFile_, array $_data_ = null, boolean $_return_ = false ) : string | ||
$_viewFile_ | string | view file |
$_data_ | array | data to be extracted and made available to the view file |
$_return_ | boolean | whether the rendering result should be returned as a string |
return | string | the rendering result. Null if the rendering result is not required. |
function renderViewFile($_viewFile_, $_data_ = null, $_return_ = false)
{
// we use special variable names here to avoid conflict when extracting data
if (is_array($_data_)) {
extract($_data_, EXTR_PREFIX_SAME, 'data');
} else {
$data = $_data_;
}
if ($_return_) {
ob_start();
ob_implicit_flush(false);
require $_viewFile_;
return ob_get_clean();
} else {
require $_viewFile_;
}
}