简体   繁体   English

Laravel在刀片视图引擎的html标签中的@yield

[英]Laravel's @yield inside html tag for blade view engine

Is this possible? 这可能吗?

<html @yield( 'AngularNamespace' )>
</html>

Obviously the above doesn't work... 显然以上方法不起作用...

It works for me. 这个对我有用。

As long as your other template file has 只要您的其他模板文件具有

@section('AngularNamespace', 'NameSpaceHere')

Its best to just pass a variable into your view, or create a view composer to bind the variable to that particular view. 最好只是将变量传递到视图中,或者创建一个视图编辑器以将变量绑定到该特定视图。

Controller: 控制器:

return View::make('myView', ['AngularNamespace' => $AngularNamespace]);

Or View Composer: View Composer:

View::composer(['layouts.master'], function($view){

    $view->with('AngularNamespace', 'myNameSpace');

});

View: 视图:

<html {{ $AngularNamespace }} >
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM