About this plugin
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()
jpg" /> @endif
Turns into…
jpg” />
the loop
@wpposts <a href="{{the_permalink()}}">{{the_title()}}</a><br> @wpempty <p>404</p> @wpend
Turns into…
<a href="”>
404
wordpress query
') }}</li> @wpend </ul>
Turns into….
>
>
>
- <a href="”>
-
Advanced Custom Fields
<ul> @acfrepeater('images') <li>{{ get_sub_field( 'image' ) }}</li> @acfend </ul>
Turns into…
- <img src="” />
Including other templates
To include a file with blade use:
@include(‘header’)
php”. g. the_header(), will not be compiled by Blade, however the php code in the file is still executed.
Layouts
php:
@yield(‘content’)
php:
@layout(‘master’)
@section('content') <p>Lorem ipsum</p> @endsection
See the Blade documentation for more info.
com/MikaelMattsson/blade