Blade
is a simple, yet powerful templating engine provided with [Laravel] (http://laravel.com) PHP framework.
These snippets works with blade files (.blade.php
) either with php syntax or with blade syntax using: PHP - Laravel Blade available from [Laravel Blade Highlighter] (https://github.com/Medalink/laravel-blade) package.
##Usage
When you're on a blade file, type the snippet shortcut then press tab
key.
##Installation
Via Package Manager
search for Blade Snippets
then click/tap…wait a sec and tadam!
Or clone this repository into your Packages folder:
git clone https://github.com/dev4dev/blade-snippets.git
Or download the snippets zip file and unzip it into your Packages folder.
##Available snippets
Shortcut | Result |
---|---|
can | @can('policy ', $model) {{-- expr --}} @endcan |
cane | @can('policy ', $model) {{-- expr --}} @else {{-- expr --}} @endcan |
ext | @extends('name ') |
lay | @layout('name ') |
sec | @section('name ') {{-- expr --}} @endsection |
secy | @section('name ') {{-- expr --}} @yield_section |
hass | @hasSection('name ') {{-- expr --}} @else {{-- expr --}} @endif |
yl | @yield('section ', 'default ') |
lsec | @section('name ') {{-- expr --}} @show |
par | @parent |
stack | @stack('name ') |
push | @push('name ') {{-- expr --}} @endpush |
!! | {!! $var !!} |
}} | {{ escaped output }} |
inc | @include('view.name ', ['some' => 'data'] ) |
if | @if (condition ) {{-- expr --}} @endif |
ife | @if (condition ) {{-- expr --}} @else {{-- expr --}} @endif |
foreach | @foreach($array as $element ) {{-- expr --}} @endforeach |
fore | @forelse ($array as $element ) {{-- expr --}} @endforelse |
for | @for ($i = 0 ; $i < … ; $i++ ) {{-- expr --}} @endfor |
each | @each ('item.view ', $items , 'item ', 'empty.view ') |
trans | {{ trans('language.line ') }} |
route | {{ route('name ') }} |
asset | {{ asset('path ') }} |
url | {{ url('path ') }} |
while | @while (condition ) {{-- expr --}} @endwhile |
unless | @unless (condition ) {{-- expr --}} @endunless |
choise | @choice('language.line ', $number ) |
comment | {{-- comment --}} |
lang | @lang('language.line ', ['variable => 'replacement ']) |
inject | @inject('name ', 'App\Services\ServiceName ') |
##Envoy snippets
Snippets for Laravel Envoy.
Shortcut | Result |
---|---|
serv | @servers(['web ' => 'user@192.168.1.1 ']) |
task | @task('foo ') command @endtask |
set | @setup {{-- expr --}} @endsetup |
mac | @macro('deploy ') command @endmacro |
aft | @after hip @endafter |
hip | @hipchat('token', 'room', 'Envoy', "$task ran in the $env environment.") |
sla | @slack('hook', 'channel', 'message') |
##Blade Wordpress Plugin
Snippets for Blade Wordpress Plugin.
Shortcut | Result |
---|---|
wpp | @wpposts {{-- expr --}} @wpempty {{-- empty expr --}} @wpend |
wpq | @wpquery (['post_type ' => 'post ']){{-- expr --}} @wpempty {{-- empty expr --}} @wpend |
acf | @acfrepeater ('fieldname '){{-- expr --}} {{ get_sub_field(' fieldname ') }}@acfend |
Original snippets by: @dev4dev
Cool Readme formatting and latest updates belong to:
- Github: @AAlakkad.
- Twitter: @Am_Alakkad.
- Email: am.alakkad@gmail.com.