[英]Blade templating (Laravel) overwrite issues
I have a "master" layout that has a section: @yield('other-scripts')
我有一个包含以下部分的“主”布局:
@yield('other-scripts')
I use this master template in another view ( especie.blade.php
): 我在另一个视图(
especie.blade.php
)中使用此主模板:
@extends('layouts.master')
@include('layouts.editarEspecie')
@section('other-scripts')
{{ HTML::script('js/lightbox.js') }}
@stop
Inside layouts.editarEspecie
, @section('other-scripts')
is also overwritten: 内部
layouts.editarEspecie
, @section('other-scripts')
layouts.editarEspecie
@section('other-scripts')
也被覆盖:
@section('other-scripts')
{{ HTML::script('js/chosen.jquery.js') }}
{{ HTML::script('js/chosenScriptModal.js') }}
{{ HTML::script('js/scripts.js') }}
@stop
The problem is that @include('layouts.editarEspecie')
goes first, so @section('other-scripts')
never adds the part inside especie.blade.php
. 问题是
@include('layouts.editarEspecie')
首先出现,因此@section('other-scripts')
从未在especie.blade.php
添加该部分。
What can I do so that both part are added and it ends like this? 我该怎么做才能将两个部分都添加进来并以这种方式结束?
{{ HTML::script('js/chosen.jquery.js') }}
{{ HTML::script('js/chosenScriptModal.js') }}
{{ HTML::script('js/scripts.js') }}
{{ HTML::script('js/lightbox.js') }}
PS: I do this because lightbox.js
is always necessary, but chosen.jquery.js, chosenScriptModal.js, scripts.js
may not always be needed. PS:之所以这样做,是因为
lightbox.js
始终是必需的,但chosen.jquery.js, chosenScriptModal.js, scripts.js
总是需要chosen.jquery.js, chosenScriptModal.js, scripts.js
。
Inside layouts.editarEspecie
dont have a "section" - just have this: 内部
layouts.editarEspecie
没有“部分”-只需执行以下操作:
{{ HTML::script('js/chosen.jquery.js') }}
{{ HTML::script('js/chosenScriptModal.js') }}
{{ HTML::script('js/scripts.js') }}
Then those 3 lines will always be included. 然后,将始终包括这3行。
The thing is, I don´t want those 3 lines to always go inside layouts.editarEspecie, just when certain conditions are met (not shown here)
问题是,我不希望那三行总是在满足某些条件时才进入layouts.editarEspecie内(此处未显示)
ummmmm.. i know its like the fastest thing ever but you can always PHP if it ummmmm ..我知道它就像有史以来最快的东西,但如果有的话,您可以随时使用PHP
<?php
if (condition)
{
?>
{{ script here}}
<?php
}
else
{}
?>
Sorry for lazy explanation but i am sure you get the hint 抱歉,我的解释很懒惰,但我相信您会得到提示
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.