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 @extendsmethod 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.phpis in app/viewsand my master.blade.php(The layout file) is in app/views/layoutsI use the @extendsfunction like:
如果我index.blade.php在app/views并且我的master.blade.php(布局文件)在app/views/layouts我使用的@extends函数中,如:
@extends('layouts.master')
Which results in the application going into the layoutsfolder 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 @extendsto have the 404.blade.phpextend the master.blade.phpbut 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 @extendsfunction
TL:DR如何在@extends函数中上移一个文件夹
Regards.
问候。
回答by Thomas Kim
@extendsis relative to the root of your view directory.
@extends相对于您的视图目录的根目录。
So when you do @extends('layouts.master'), it will always be views/layouts/master.blade.phpno 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')

