laravel 刀片模板@extend 上一个文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34800078/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Blade templating @extend go up a folder
提问by Mike Donkers
Alright so I know about the Blade @extends
method to enter a folder, but how about leaving one to enter another? How would that be achieved?
好的,所以我知道 Blade@extends
方法可以进入一个文件夹,但是离开一个进入另一个如何?这将如何实现?
For example:
例如:
If my index.blade.php
is in app/views
and my master.blade.php
(The layout file) is in app/views/layouts
I use the @extends
function like:
如果我index.blade.php
在app/views
并且我的master.blade.php
(布局文件)在app/views/layouts
我使用的@extends
函数中,如:
@extends('layouts.master')
Which results in the application going into the layouts
folder as expected.
这会导致应用程序layouts
按预期进入文件夹。
But now, I have the following directory structure;
但是现在,我有以下目录结构;
app/
views/
errors/
404.blade.php
layouts/
master.blade.php
index.blade.php
Now what I want to do is use @extends
to have the 404.blade.php
extend the master.blade.php
but I have no idea as to how to "go up a folder".
现在我想做的是使用@extends
有404.blade.php
延长master.blade.php
,但我不知道是如何“上一个文件夹”。
TL:DRHow do I go up one folder in the @extends
function
TL:DR如何在@extends
函数中上移一个文件夹
Regards.
问候。
回答by Thomas Kim
@extends
is relative to the root of your view directory.
@extends
相对于您的视图目录的根目录。
So when you do @extends('layouts.master')
, it will always be views/layouts/master.blade.php
no matter the location of the view that is extending it.
因此,当您这样做时@extends('layouts.master')
,它始终与views/layouts/master.blade.php
扩展它的视图的位置无关。
In other words, you change nothing and just do:
换句话说,您什么都不做,只需执行以下操作:
@extends('layouts.master')