本文整理匯總了PHP中Blade::compile方法的典型用法代碼示例。如果您正苦於以下問題:PHP Blade::compile方法的具體用法?PHP Blade::compile怎麽用?PHP Blade::compile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Blade
的用法示例。
在下文中一共展示了Blade::compile方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: sharpen
/**
* Register the Blade view engine with Laravel.
*
* @return void
*/
public static function sharpen()
{
Event::listen(View::engine, function ($view) {
// The Blade view engine should only handle the rendering of views which
// end with the Blade extension. If the given view does not, we will
// return false so the View can be rendered as normal.
if (!str_contains($view->path, BLADE_EXT)) {
//return;
}
$compiled = Blade::compiled($view->path);
// If the view doesn't exist or has been modified since the last time it
// was compiled, we will recompile the view into pure PHP from it's
// Blade representation, writing it to cached storage.
if (!file_exists($compiled) or Blade::expired($view->view, $view->path)) {
file_put_contents($compiled, Blade::compile($view));
}
$view->mytplengine or $view->mytplengine = new \TemplateEngine(TEMPLATEPATH);
//kd($compiled);
$compiled = $view->mytplengine->display($compiled, true);
$view->path = $compiled;
// Once the view has been compiled, we can simply set the path to the
// compiled view on the view instance and call the typical "get"
// method on the view to evaluate the compiled PHP view.
return ltrim($view->get());
});
}