此包已被弃用且不再维护。未建议替代包。

用于增强Laravel blade视图管理的工具集

5.2.0.0 2016-01-19 15:04 UTC

This package is not auto-updated.

Last update: 2020-07-29 13:43:55 UTC


README

用于增强Laravel blade视图管理的工具集。

使用composer安装

composer require white-frame/view:0.*

注册服务提供者

WhiteFrame\View\ViewServiceProvider::class

将视图嵌套到其他视图中(连接blade视图部分)

门面 WhiteFrame\View 允许您将blade视图嵌套到其他blade视图中。如果您有一个需要动态向部分等添加内容的模块化应用程序,这可能很有用。

简单示例

这是您的通用 layout.blade.php,其中包含一个 sidebar-menu 部分。此部分有两个默认链接,需要从动态模块中填充其他新菜单链接。

<!DOCTYPE html>
[ ... ]
<body>
<section class="sidebar">
	<ul class="sidebar-menu">
		@section("sidebar-menu")
		  <li><a href="{{ url('layout_page_1') }}">Layout page 1<</a></li>
		  <li><a href="{{ url('layout_page_2') }}">Layout page 2</a></li>
		@show
	</ul>
</section>
[...]
</body>
</html>

在特定模块中,创建一个要包含的部分视图,例如 my_module::layout.menu

@section("sidebar-menu")
	@parent
	
	<li><a href="{{ url('my_module/my_page') }}">My module page</a></li>
@stop

然后使用 WhiteFrame\View 将此部分视图嵌套到布局部分中,在模块的服务提供者中。

public function boot()
{
  \WhiteFrame\View::nest('layout', 'my_module::layout.menu');
  /*
   * You can use 3 params : nest view (host), nested view (child), array containing datas for nested view (optionnal)
   */
}