本文整理汇总了PHP中Blade::view方法的典型用法代码示例。如果您正苦于以下问题:PHP Blade::view方法的具体用法?PHP Blade::view怎么用?PHP Blade::view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Blade
的用法示例。
在下文中一共展示了Blade::view方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: view
/**
* Метод подключения шаблонов
* @param string $view имя шаблона
* @param array $params массив параметров
* @param boolean $return выводить или возвращать код
* @return string сформированный код
*/
public static function view($template, $params = [], $return = false)
{
$blade = new Blade(APP . '/views', STORAGE . '/cache');
if ($return) {
return $blade->view()->make($template, $params)->render();
} else {
echo $blade->view()->make($template, $params)->render();
}
}
示例2: blade_include
/**
* Include the template
* @return string
*/
public function blade_include($template)
{
if (!$template) {
return $template;
}
// Noting to do here. Come back later.
// all templates for our engine must live in the template directory
if (stripos($template, get_template_directory()) === FALSE) {
return $template;
}
if ($this->viewExpired($template)) {
// get the base name
$file = basename($template);
// with a blade extension, we have to do this because blade wont recognize the root files without the .blade.php extension
$blade = str_replace('.php', '.blade.php', $file);
$blade_file = $this->view_cache . '/' . $blade;
// get the code
$code = file_get_contents($template);
// add the code to the cached blade file
file_put_contents($blade_file, $code);
// blade friendly name
$view = str_replace('.php', '', $file);
// find a controller
$controller = $this->getController($view);
// run the blade code
echo $this->blade->view()->make('cache.' . $view)->with(['data' => $controller ? $controller->process() : []])->render();
// halt including
return '';
} else {
// get the base name
$file = basename($template);
// blade friendly name
$view = str_replace('.php', '', $file);
// find a controller
$controller = $this->getController($view);
// run the blade code
echo $this->blade->view()->make('cache.' . $view)->with(['data' => $controller ? $controller->process() : []])->render();
// halt including
return '';
}
// return an empty string to stop wordpress from including the template when we are doing it
return $template;
}
示例3: bladePage
public static function bladePage($page = '', $data = '', $obGetContents = false)
{
return Blade::view($page, $data, $obGetContents);
}