【发布时间】:2015-08-17 08:42:49
【问题描述】:
当在 laravel Blade 中扩展视图时,有多个插入位置,可以这样做:
<html>
<head>
<title>This is app/view/layout/default.blade.php</title>
{{ HTML::script('js/jquery-2.1.3.min.js') }}
{{ HTML::script('js/angular.js') }}
@yield('extra_libraries')
</head>
<body>
<div class="left-menu-bar">
@yield('left-menu-bar')
</div>
<div class="main-content">
@yield('main-content')
</div>
</body>
</html>
那么,在使用布局的时候,
@extend ("layout.default")
@section('extra_libraries')
{{ HTML::script('js/underscore.js') }}
@stop
@section('left-menu-bar')
<a href="http://www.google.com/">testing button</a>
@stop
@section('main-content')
testing
@stop
当我不扩展但将另一个刀片包含到我当前的刀片中时,我想要的是类似的功能。即这样的事情:
<html>
<head>
<title>This is app/view/layout/default.blade.php</title>
{{ HTML::script('js/jquery-2.1.3.min.js') }}
{{ HTML::script('js/angular.js') }}
</head>
<body ng-app="myTestingApp">
<div ng-controller="testing">
@include('components.componentA.htmlComponent')
@include('components.componentB.htmlComponent')
</div>
<script>
var app = angular.module('myTestingApp', []).controller("testing", testingController);
function testingController($scope) {
@include('components.componentA.angularCode')
@include('components.componentB.angularCode')
}
</script>
</body>
</html>
componentA 应该是一个包含 anguarCode 和 htmlComponent 的刀片文件。我知道我可以将它们分成 2 个文件,但我想看看是否有办法将它们放在同一个文件中,因为它们密切相关。 laravel 刀片中是否有默认功能来实现这一点?
附:这个例子说明了为什么我想把它们放在一起,如果你知道 angularjs。
【问题讨论】:
标签: php laravel-4 blade php-include