pojokcodeid.nvim-lazy/my-snippets/laravel-blade/snippets/snippets.json

461 lines
11 KiB
JSON
Raw Normal View History

2023-01-15 00:19:37 +07:00
{
/* Extending a layout */
"Extend layout": {
"prefix": "b:extends",
"body": "@extends('${1:name}')",
"description": "extends view layout"
},
"Yield content": {
"prefix": "b:yield",
"body": "@yield('${1:name}')",
"description": "yield content section"
},
"Content Section": {
"prefix": "b:section",
"body": [
"@section('${1:name}')",
" $2",
"@endsection"
],
"description": "content section"
},
"Content Section Show": {
"prefix": "b:section-show",
"body": [
"@section('$1')",
" $2",
"@show"
],
"description": "content section show"
},
/* Include sub-view */
"Include view": {
"prefix": "b:include",
"body": "@include('${1:name}')",
"description": "include view"
},
/* If Statements */
"If-block": {
"prefix": "b:if",
"body": [
"@if ($1)",
" $2",
"@endif"
],
"description": "@if block"
},
"If-else-block": {
"prefix": "b:if-else",
"body": [
"@if ($1)",
" $2",
"@else",
" $3",
"@endif"
],
"description": "if-else block"
},
"Has Section": {
"prefix": "b:has-section",
"body": [
"@hasSection ('${1:name}')",
" $2",
"@else",
" $3",
"@endif"
],
"description": "@hasSection condition"
},
"Unless-block": {
"prefix": "b:unless",
"body": [
"@unless ($1)",
" $2",
"@endunless"
],
"description": "@unless block"
},
/* Loops */
"For-block": {
"prefix": "b:for",
"body": [
"@for (\\$i = ${1:0}; \\$i < ${2:\\$count}; \\$i++)",
" $3",
"@endfor"
],
"description": "@for block"
},
"Foreach-block": {
"prefix": "b:foreach",
"body": [
"@foreach (${1:\\$collection} as ${2:\\$item})",
" $3",
"@endforeach"
],
"description": "@foreach block"
},
"forelse-block": {
"prefix": "b:forelse",
"body": [
"@forelse (${1:\\$collection} as ${2:\\$item})",
" $3",
"@empty",
" $4",
"@endforelse"
],
"description": "@forelse block"
},
"while-block": {
"prefix": "b:while",
"body": [
"@while ($1)",
" $2",
"@endwhile"
],
"description": "@while block"
},
/* Rendering views for collections */
"each loop": {
"prefix": "b:each",
"body": "@each('${1:view.name}', ${2:\\$collection}, '${3:variable}', '${4:view.empty}')",
"description": "@each loop"
},
/* Comments */
"blade comment": {
"prefix": "b:comment",
"body": "{{-- ${1:comment} --}}",
"description": "comment block"
},
/* Display Data */
"blade echo-data": {
"prefix": "b:echo",
"body": "{{ ${1:\\$data} }}",
"description": "echo data"
},
"blade echo-unescaped-data": {
"prefix": "b:echo-html",
"body": "{!! ${1:\\$html_data} !!}",
"description": "echo unescaped data (allow html outputs)"
},
"blade echo-untouch": {
"prefix": "b:echo-raw",
"body": "@{{ ${1:variable} }}",
"description": "echo untouched data (allow javascript expression)"
},
"blade verbatim": {
"prefix": "b:verbatim",
"body": [
"@verbatim",
"{{ ${1:variable} }}",
"@endverbatim"
],
"description": "displaying JavaScript variables in a large portion of your template"
},
/* Stacks */
"Push stack": {
"prefix": "b:push",
"body": [
"@push('${1:name}')",
" $2",
"@endpush"
],
"description": "@push stack"
},
"Stack": {
"prefix": "b:stack",
"body": "@stack('${1:name}')",
"description": "@stack"
},
/* Service Injection */
"inject service": {
"prefix": "b:inject",
"body": "@inject('${1:name}', '${2:class}')",
"description": "@inject Service"
},
/* Authorizing */
"can": {
"prefix": "b:can",
"body": [
"@can('${1:update}', ${2:\\$post})",
" $3",
"@endcan"
],
"description": "display a portion of the page only if the user is authorized to perform a given action."
},
"can-elsecan": {
"prefix": "b:can-elsecan",
"body": [
"@can('${1:update}', ${2:\\$post})",
" $3",
"@elsecan('create', App\\Models\\\\${4:Post}::class)",
" $5",
"@endcan"
],
"description": "display a portion of the page only if the user is authorized to perform a given action."
},
"canany": {
"prefix": "b:canany",
"body": [
"@canany(['update', 'view', 'delete'], ${1:\\$post})",
" $2",
"@endcanany"
],
"description": "display a portion of the page only if the user is authorized to perform a given action."
},
"canany-elsecanany": {
"prefix": "b:canany-elsecanany",
"body": [
"@canany(['update', 'view', 'delete'], ${1:\\$post})",
" $2",
"@elsecanany(['create'], App\\Models\\\\${3:Post}::class)",
" $4",
"@endcanany"
],
"description": "display a portion of the page only if the user is authorized to perform a given action."
},
"cannot": {
"prefix": "b:cannot",
"body": [
"@cannot('${1:update}', ${2:\\$post})",
" $3",
"@endcannot"
],
"description": "display a portion of the page only if the user is authorized to perform a given action."
},
"cannot-elsecannot": {
"prefix": "b:cannot-elsecannot",
"body": [
"@cannot('${1:update}', ${2:\\$post})",
" $3",
"@elsecannot('create', App\\Models\\\\${5:Post}::class)",
" $6",
"@endcannot"
],
"description": "display a portion of the page only if the user is authorized to perform a given action."
},
/* v5.3 - $loop variable */
"loop": {
"prefix": "b:loop",
"body": [
"\\$loop->${1:first}"
],
"description": "$loop->(index|remaining|count|first|last|depth|parent)"
},
"loop first": {
"prefix": "b:loop-first",
"body": [
"@if (\\$loop->first)",
" ${1:{{-- This is the first iteration --\\}\\}}",
"@endif"
],
"description": "$loop->first"
},
"loop last": {
"prefix": "b:loop-last",
"body": [
"@if (\\$loop->last)",
" ${1:{{-- This is the last iteration --\\}\\}}",
"@endif"
],
"description": "$loop->last"
},
"php": {
"prefix": "b:php",
"body": [
"@php",
" $1",
"@endphp"
],
"description": "@php block code in view"
},
"includeIf": {
"prefix": "b:includeIf",
"body": "@includeIf('${1:view.name}'${2:, ['some' => 'data']})",
"description": "include a view that may or may not be present, you should use the @includeIf directive"
},
/* v5.4 */
"component": {
"prefix": "b:component",
"body": [
"@component('$1')",
" $2",
"@endcomponent"
],
"description": "component"
},
"slot": {
"prefix": "b:slot",
"body": [
"@slot('$1')",
" $2",
"@endslot"
],
"description": "slot"
},
"isset": {
"prefix": "b:isset",
"body": [
"@isset(${1:\\$record})",
" $2",
"@endisset"
],
"description": "isset"
},
"empty": {
"prefix": "b:empty",
"body": [
"@empty(${1:\\$record})",
" $2",
"@endempty"
],
"description": "empty"
},
"error": {
"prefix": "b:error",
"body": [
"@error('${1:record}')",
" $2",
"@enderror"
],
"description": "error"
},
"includeWhen": {
"prefix": "b:includeWhen",
"body": "@includeWhen(${1:\\$boolean}, '${2:view.name}', [${3:'some' => 'data'}])",
"description": "includeWhen"
},
/* v5.5 */
"auth": {
"prefix": "b:auth",
"body": [
"@auth",
" $1",
"@endauth"
],
"description": "auth"
},
"guest": {
"prefix": "b:guest",
"body": [
"@guest",
" $1",
"@endguest"
],
"description": "guest"
},
"switch": {
"prefix": "b:switch",
"body": [
"@switch(${1:\\$type})",
" @case(${2:1})",
" $3",
" @break",
" @case(${4:2})",
" $5",
" @break",
" @default",
" $6",
"@endswitch"
],
"description": "switch"
},
"includeFirst": {
"prefix": "b:includeFirst",
"body": "@includeFirst(['${1:view.name}', '${2:variable}'], [${3:'some' => 'data'}])",
"description": "includeFirst"
},
/* v5.6 */
"csrf": {
"prefix": "b:csrf",
"body": "@csrf",
"description": "form csrf field"
},
"method": {
"prefix": "b:method",
"body": "@method($1)",
"description": "form method field"
},
"dump": {
"prefix": "b:dump",
"body": "@dump($1)",
"description": "dump"
},
/* Retrieving Translation Strings */
"lang": {
"prefix": "b:lang",
"body": "@lang('${1:messages.welcome}')",
"description": "lang"
},
/* v6.x */
"includeUnless": {
"prefix": "b:includeUnless",
"body": "@includeUnless(${1:\\$boolean}, '${2:view.name}', [${3:'some' => 'data'}])",
"description": "includeUnless"
},
/* v7.x */
"props": {
"prefix": "b:props",
"body": "@props(['${1:propName}'])",
"description": "Blade component data properties"
},
"env": {
"prefix": "b:env",
"body": [
"@env('${1:staging}')",
" $2",
"@endenv"
],
"description": "env"
},
"production": {
"prefix": "b:production",
"body": [
"@production",
" $1",
"@endproduction"
],
"description": "production"
},
"once": {
"prefix": "b:once",
"body": [
"@once",
" $1",
"@endonce"
],
"description": "define a portion of template that will only be evaluated once per rendering cycle"
},
/* v8.x */
"aware": {
"prefix": "b:aware",
"body": "@aware(['${1:propName}'])",
"description": "Accessing data from a parent component (Laravel 8.64)"
},
"js": {
"prefix": "b:js",
"body": "@js(${1:\\$data})",
"description": "This directive is useful to properly escape JSON within HTML quotes"
},
"class": {
"prefix": "b:class",
"body": "@class(['${1:p-4}', ${2:'font-bold' => true}])",
"description": "conditionally compiles a CSS class string. (Laravel 8.51)"
},
/* v9.x */
"checked": {
"prefix": "b:checked",
"body": "@checked(${1:true})",
"description": "This directive will echo checked if the provided condition evaluates to true (Laravel 9.x)"
},
"selected": {
"prefix": "b:selected",
"body": "@selected(${1:true})",
"description": "The @selected directive may be used to indicate if a given select option should be \"selected\" (Laravel 9.x)"
},
"disabled": {
"prefix": "b:disabled",
"body": "@disabled(${1:true})",
"description": "The @disabled directive may be used to indicate if a given element should be \"disabled\" (Laravel 9.x)"
}
}