Snippets for blade template engine

Overview

Blade Snippets for Sublime Text

Blade is a simple, yet powerful templating engine provided with Laravel 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 package.

Usage

When you’re editing 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!

Blade Snippets

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

Template management

Shortcut Result
lay @layout('name')
ext @extends('name')
sec @section('name')
{{-- expr --}}
@endsection
secy @section('name')
{{-- expr --}}
@yield_section
secsim @section('name', 'content')
hass @hasSection('name')
{{-- expr --}}
@else
{{-- expr --}}
@endif
yl @yield('section', 'default')
lsec @section('name')
{{-- expr --}}
@show
par @parent

Components & Slots

Shortcut Result
comp @component('component', 'data')
{{-- expr --}}
@endcomponent
slot @slot('slot')
{{-- expr --}}
@endslot

Displaying data

Shortcut Result
!! {!! $var !!}
}} {{ escaped output }}

Blade & JavaScript Frameworks

Shortcut Result
@{{ @{{ javascript }}
verb @verbatim
{{-- code --}}
@endverbatim

Control Structures

Shortcut Result
if @if (condition)
{{-- expr --}}
@endif
ife @if (condition)
{{-- expr --}}
@else
{{-- expr --}}
@endif
eif @elseif (condition)
{{-- expr --}}
switch @switch($i)
    @case(case1)
        First case...
        @break

    @default
            Default case...
@endswitch
unless @unless (condition)
{{-- expr --}}
@endunless
for @for ($i = 0; $i < ; $i++)
{{-- expr --}}
@endfor
foreach @foreach($array as $element)
{{-- expr --}}
@endforeach
fore @forelse ($array as $element)
{{-- expr --}}
@endforelse
while @while (condition)
{{-- expr --}}
@endwhile
inc @include('view.name', ['some' => 'data'])
incif @includeIf('view.name', ['some' => 'data'])
incwhen @includeWhen(boolean, 'view.name', ['some' => 'data'])
incf @includeFirst(['custom.admin', 'admin'], ['some' => 'data'])
each @each ('item.view', $items, 'item', 'empty.view')
continue @continue('condition')
break @break('condition')
php @php
{{-- expr --}}
@endphp
empty @empty (condition)
{{-- expr --}}
@endempty
isset @isset (condition)
{{-- expr --}}
@endisset

Stacks

Shortcut Result
stack @stack('name')
push @push('name')
{{-- expr --}}
@endpush
prepend @prepend('name')
{{-- expr --}}
@endprepend

Authentication Shortcuts

Shortcut Result
auth @auth('name')
{{-- expr --}}
@endauth
guest @guest('name')
{{-- expr --}}
@endguest

Policies

See the Laravel Policies documentation.

Shortcut Result
can @can('policy', Model::class)
{{-- expr --}}
@endcan
cane @can('policy', $model)
{{-- expr --}}
@else
{{-- else expr --}} @endcan
cannot @cannot('policy', Model::class)
{{-- expr --}}
@endcannot
cannote @cannot('policy', $model)
{{-- expr --}}
@else
{{-- else expr --}} @endcannot
canany @canany('policy', $model)
{{-- expr --}} @endcanany
cananye @canany(['policy', 'policy'], $model)
{{-- expr --}}
@elsecanany(['policy', 'policy'], $model)
{{-- expr --}}
@endcanany

Miscellaneous

Shortcut Result
route {{ route('name') }}
asset {{ asset('path') }}
url {{ url('path') }}
choice @choice('language.line', $number)
comment {{-- comment --}}
inject @inject('name', 'App\Services\ServiceName')
trans {{ trans('language.line') }}
lang @lang('language.line', ['variable => 'replacement'])
__ {{ __('language.line') }}
csrf @csrf
method @method('PUT')
json @json(expression)
dump @dump(expression)

Envoy snippets

Snippets for Laravel Envoy.

Shortcut Result
serv @servers(['web' => '[email protected]'])
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')
story @story('deploy')
command
@endstory

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: GitHub: @AAlakkad.

Contributors

Comments
  • Snippet completion box doesn't show up

    Snippet completion box doesn't show up

    If I start typing ext, I expect to see a completion box showing snippets matching ext, however this box does not show. Any thoughts on how I can fix this? The snippet will insert itself if I tab after typing in "ext"

    opened by jasonmng 3
  • Reorganize README and add snippets

    Reorganize README and add snippets

    I reorganized the README since the number of snippets keeps growing and upcoming Components and Slots will just make this more complicated. Also added some missing snippets.

    opened by redgluten 2
  • Add snippet for the new alternative to the Laravel trans helper

    Add snippet for the new alternative to the Laravel trans helper

    opened by gerardreches 1
  • Please prefix your snippet with some text

    Please prefix your snippet with some text

    Like, it will be better if your snippets prefix with e.g blade-{command}. It will be better. As currently it collides with default snippets. Please do it as soon as possible. Or allow me to do so, if your are willing to accept pull request.

    opened by mbaljeetsingh 1
  • Blade Scope

    Blade Scope

    Thanks for making this snippets. Before I submit a pull request, I have a question. Why is the scope for all snippets text.html.laravel-blade, text.html, when Blade's scope is just text.html.laravel-blade?

    With this scope all blade snippets trigger in regular PHP files in my Sublime 2 installation.

    opened by olivervogel 1
  • Getting additional @ when using snippets

    Getting additional @ when using snippets

    I noticed that whenever I use the snippets I get an additional '@'

    So when I try it out it gives me this

    @@if (condition)
        {{-- expr --}}
    @endif
    
    @@foreach ($array as $element)
        {{-- expr --}}
    @endforeach
    

    snippet-bug

    opened by lozadaOmr 1
  • Installation via Package manager

    Installation via Package manager

    Hello, If you could add the installation via Package Manager (search for: Blade Snippets) to the installation section in the readme file, it would be wonderful!

    opened by AmmarCodes 1
  • Adjust selectors for Sublime Text 4 and refactored Blade syntax

    Adjust selectors for Sublime Text 4 and refactored Blade syntax

    This commit...

    1. adjusts scope to
      a) be forward compatible with a rewritten Laravel Blade syntax, which uses text.html.blade main scope.
      see: https://github.com/Medalink/laravel-blade/pull/195
      b) avoid snippets from being triggered within directives or embedded php source code.
    2. removes template comments from snippet files.
    3. modifies indentation from 4 space to tab.

    Note: Overall content of snippets is maintained unchanged.

    opened by deathaxe 0
  • Missing directives

    Missing directives

    There are some more Blade directives, which are not in this plugin.

    • @json - Laravel 5.5 and higher
    • @includeWhen - Laravel 5.4 and higher
    • @includeFirst - Laravel 5.5 and higher
    • @prepend - Laravel 5.6 and higher
    • @csrf - Laravel 5.6 and higher
    • @method - Laravel 5.6 and higher
    • @elseif
    • @canany - Laravel 5.6.23 and higher
    • @dump - Laravel 5.6.8 and higher
    opened by arxeiss 0
Releases(pre5.4)
Owner
Alex Antonyuk
🌟
Alex Antonyuk
A Laravel Code Generator based on your Models using Blade Template Engine

Laravel Code Generator is a PHP Laravel Package that uses Blade template engine to generate code for you. The difference between other code generators

Victor Yoalli 59 Dec 5, 2022
Blade UI Kit is a set of renderless components to utilise in your Laravel Blade views

Blade UI Kit is a set of renderless components to utilise in your Laravel Blade views. In all essence, it's a collection of useful utilities, connecting the dots between different parts of the TALL stack. It was made for Blade, Laravel's powerful templating engine.

Blade UI Kit 1.2k Jan 5, 2023
This package adds syntax definitions for the Laravel Blade engine.

Laravel Blade Highlighter This package adds syntax definitions for the Laravel Blade engine. Works with various Sublime Text version, for older/specif

Eric Percifield 393 Dec 24, 2022
A general-purpose parser for Laravel's Blade templating engine.

A general-purpose parser for Laravel's Blade templating engine. This is where your description should go. Try and limit it to a paragraph or two. Cons

Ryan Chandler 6 Feb 18, 2022
Use Laravel's Blade templating engine outside of Laravel.

Use Laravel's Blade templating engine outside of Laravel. This package provides a standalone version of Laravel's Blade templating engine for use outs

Ryan Chandler 22 Jan 2, 2023
Blade is a simple, yet powerful templating engine provided for the Slim Framework

slim-blade Blade is the default template engine of Laravel. The main advantage of Blade is template inheritance whilst using plain PHP. This package a

Kevin Darren 32 May 24, 2021
Use Laravel's blade engine as a CLI for rendering files.

Blade CLI Use Laravel's blade engine as a CLI for rendering files. Introduction This package customizes and extends several of the Illuminate\View cla

Sergio Compean 31 Oct 21, 2022
Create Laravel views (blade template) using 'php artisan' command-line interface

About LaraBit Have you ever wonder to create Laravel views (Blade Templates) using the same type of artisan commands that you usually use to create ne

Ragib MRB 5 Oct 15, 2021
An opinionated blade template formatter for Laravel that respects readability

blade-formatter An opinionated blade template formatter for Laravel that respects readability Online Demo Features Automatically Indents markup inside

Shuhei Hayashibara 277 Dec 26, 2022
Shows the path of each blade file loaded in a template

Laravel Tracer Tracer shows the paths of all the Blade files that are loaded into your templates. This could be very convenient for a number of reason

Appstract 97 Oct 1, 2022
View template engine of PHP extracted from Laravel

Blade 【简体中文】 This is a view templating engine which is extracted from Laravel. It's independent without relying on Laravel's Container or any others.

Scholer 143 Dec 13, 2022
Is an Extension of Laravel View Class which compiles String Template on the fly. It automatically detects changes on your string template and recompiles it if needed.

Laravel-fly-view Is an Extension of Laravel View Class which compiles String Template on the fly. It automatically detects changes on your string temp

John Turingan 16 Jul 17, 2022
A package to easily make use of Iconic icons in your Laravel Blade views.

Blade Iconic A package to easily make use of Iconic icons in your Laravel Blade views. For a full list of available icons see the SVG directory. Iconi

Malik Alleyne-Jones 17 Aug 25, 2022
A package to easily make use of Simple Icons in your Laravel Blade views.

Blade Simple Icons A package to easily make use of Simple Icons in your Laravel Blade views. For a full list of available icons see the SVG directory.

UB Labs 12 Jan 17, 2022
Laravel blade directives and php helpers for serverside rendered content, based on browser window size WITHOUT css

Laravel Window Size and Breakpoints Laravel blade directives and php helpers for server side rendered content, based on browser window size WITHOUT cs

Tina Hammar 7 Nov 23, 2022
Cache chunks of your Blade markup with ease. 🔪

Blade Cache Directive Cache chunks of your Blade markup with ease. Installation You can install the package via Composer: composer require ryangjchand

Ryan Chandler 155 Dec 10, 2022
A package that uses blade templates to control how markdown is converted to HTML inside Laravel, as well as providing support for markdown files to Laravel views.

Install Install via composer. $ composer require olliecodes/laravel-etched-blade Once installed you'll want to publish the config. $ php artisan vendo

Ollie Codes 19 Jul 5, 2021
Storybook for Laravel Blade 🚀

Blast — Storybook for Laravel Blade ?? What is Blast? Blast is a low maintenance component library using Storybook Server, built to integrate into you

AREA 17 182 Jan 3, 2023
Cagilo - a set of simple components for use in your views Laravel Blade.

Cagilo - a set of simple components for use in your views Laravel Blade. Official Documentation Documentation for Cagilo can be found on its we

Cagilo 151 Dec 6, 2022