
內容簡介
Blade是Laravel的模板引擎,由Taylor Otwell開發的非常流行的php框架。此外掛將相同的模板引擎帶到WordPress中,使用模板引擎將會使得模板文件更加乾淨且快速開發,但一般的php仍可在模板文件中使用。此外掛還添加了特定於WordPress的Blade片段,請查看範例以獲得更多信息。
echo/print
{{$foo}}
變成了…
if()
@if(has_post_thumbnail())
{{the_post_thumbnail() }}
@else
<img src="{{bloginfo( 'template_url' )}}/images/thumbnail-default.jpg" />
@endif
變成了…
<img src="/images/thumbnail-default.jpg” />
the loop
@wpposts
<a href="{{the_permalink()}}">{{the_title()}}</a><br>
@wpempty
<p>404</p>
@wpend
變成了…
<a href="”>
404
wordpress查詢
<ul>
@wpquery(array('post_type' => 'post'))
<li><a href="{{the_permalink()}}">{{the_title()}}</a></li>
@wpempty
<li>{{ __('Sorry, no posts matched your criteria.') }}</li>
@wpend
</ul>
變成了….
‘post’) ); ?>
have_posts() ) : ?>
have_posts() ) : $query->the_post(); ?>
<a href="”>
高級自定義字段
<ul>
@acfrepeater('images')
<li>{{ get_sub_field( 'image' ) }}</li>
@acfend
</ul>
變成了…
<img src="” />
包含其他模板
要使用Blade包含文件,請使用:
@include(‘header’)
請注意,不應輸入“.php”。使用函數包含的文件(例如the_header())將不會被Blade編譯,但文件中的php代碼仍然會被執行。
版面配置
master.php:
@yield(‘content’)
page.php:
@layout(‘master’)
@section('content')
<p>Lorem ipsum</p>
@endsection
有關更多信息,請參閱Blade文檔。
在github上貢獻:github.com/MikaelMattsson/blade
外掛標籤
開發者團隊
原文外掛簡介
Blade is the template engine for Laravel, a very popular php framework, developed by Taylor Otwell. This plugin brings the same template engine to wordpress.
Using a template engine will result in much cleaner template files and quicker development. Normal php can still be used in the template files.
The plugin also adds a wordpress specific snippet to blade. Check out the examples for more info.
echo/print
{{$foo}}
Turns into…
if()
@if(has_post_thumbnail())
{{the_post_thumbnail() }}
@else
![]()
@endif
Turns into…
{{the_title()}}
@wpempty
404
@wpend
Turns into…
{{the_title()}}
@wpempty
@wpend
Turns into….
‘post’) ); ?>
have_posts() ) : ?>
have_posts() ) : $query->the_post(); ?>
延伸相關外掛
