/**
*
*/
public function renderView($viewCode, $viewContext = null, $viewRoot = null)
{
// Fix the view root
if (empty($viewRoot) === true) {
$viewRoot = PATH_APP . '/Views';
}
// Check whether the view exists
$pathToView = $viewRoot . '/' . $viewCode;
if (file_exists($pathToView) === false) {
\z\e(EXCEPTION_VIEW_NOT_FOUND, ['pathToView' => $pathToView, 'viewCode' => $viewCode, 'viewContext' => $viewContext]);
}
// Load the view
$view = file_get_contents($pathToView);
// Compile the view
$code = \LightnCandy\LightnCandy::compile($view, ['basedir' => [PATH_APP . '/Views'], 'fileext' => [''], 'flags' => \LightnCandy\LightnCandy::FLAG_ERROR_EXCEPTION | \LightnCandy\LightnCandy::FLAG_HANDLEBARS | \LightnCandy\LightnCandy::FLAG_RENDER_DEBUG | \LightnCandy\LightnCandy::FLAG_RUNTIMEPARTIAL | \LightnCandy\LightnCandy::FLAG_THIS, 'helpers' => ['locale' => function () {
return \z\service('manager/culture')->localeCode;
}, 'str' => function ($indexed, $associative) {
// Build arguments
$arguments = $this->buildArguments(['stringCode'], $indexed, $associative);
// Get the string
$result = \z\str($arguments['stringCode']);
return $result;
}]]);
// Build path to code
$pathToCode = '/tmp/' . sha1('fbenard/zero_' . $pathToView) . '.php';
// Get the view renderer
file_put_contents($pathToCode, $code);
$renderer = (require $pathToCode);
// Render the view
$result = $renderer($viewContext);
return $result;
}