Skip to content

Commit

Permalink
add blade snippets (#374)
Browse files Browse the repository at this point in the history
* add blade snippets

* fix json formatting
  • Loading branch information
erizo-dev authored Feb 12, 2024
1 parent b8fae73 commit b6a8d1e
Show file tree
Hide file tree
Showing 5 changed files with 631 additions and 2 deletions.
22 changes: 20 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@
"eruby",
"javascriptreact",
"htmldjango",
"astro"
"astro",
"blade"
],
"path": "./snippets/html.json"
},
Expand Down Expand Up @@ -421,9 +422,25 @@
"path": "./snippets/latex/bibtex.json"
},
{
"language": "twig",
"language": "twig",
"path": "./snippets/frameworks/twig.json"
},
{
"language": "blade",
"path": "./snippets/frameworks/blade/blade.json"
},
{
"language": "blade",
"path": "./snippets/frameworks/blade/helpers.json"
},
{
"language": "blade",
"path": "./snippets/frameworks/blade/livewire.json"
},
{
"language": "blade",
"path": "./snippets/frameworks/blade/snippets.json"
},
{
"language": ["r", "rmd"],
"path": "./snippets/r.json"
Expand Down Expand Up @@ -530,3 +547,4 @@
]
}
}

49 changes: 49 additions & 0 deletions snippets/frameworks/blade/blade.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"Blade-component": {
"prefix": "Blade::component",
"body": "Blade::component('${1:package-name}', ${2:PackageNameComponent}::class);",
"description": "Registering Package Components (AppServiceProvider boot method)"
},
"Blade-include": {
"prefix": "Blade::include",
"body": "Blade::include('${1:includes.input}', '${2:input}');",
"description": "Aliasing Includes (AppServiceProvider boot method)"
},
"Blade-if": {
"prefix": "Blade::if",
"body": [
"Blade::if('${1:env}', function ($${2:environment}) {",
" ${3:return app()->environment($$environment);}",
"});"
],
"description": "Custom If Statements (AppServiceProvider boot method)"
},
"Blade-directive": {
"prefix": "Blade::directive",
"body": [
"Blade::directive('${1:datetime}', function ($${2:expression}) {",
" ${3:return \"<?php echo ($$expression)->format('m/d/Y H:i'); ?>\";}",
"});"
],
"description": "Custom directive (AppServiceProvider boot method)"
},
"Blade-stringable": {
"prefix": "Blade::stringable",
"body": [
"Blade::stringable(function (${1:Money} $${2:money}) {",
" ${3:return $$money->formatTo('en_GB');}",
"});"
],
"description": "Custom echo handlers (AppServiceProvider boot method)"
},
"Blade-render": {
"prefix": "Blade::render",
"body": "Blade::render(${1:'Blade template string'}, ${2:\\$data});",
"description": "Transform a raw Blade template string into valid HTML (Laravel 9.x)"
},
"Blade-renderComponent": {
"prefix": "Blade::renderComponent",
"body": "Blade::renderComponent(new ${1:HelloComponent}(${2:\\$params}));",
"description": "Render a given class component by passing the component instance to the method (Laravel 9.x)"
}
}
57 changes: 57 additions & 0 deletions snippets/frameworks/blade/helpers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"Path-elixir": {
"prefix": "lv:elixir",
"body": "{{ elixir('${1:file}') }}",
"description": "(deprecated) elixir path"
},
"Path-mix": {
"prefix": "lv:mix",
"body": "{{ mix('${1:file}') }}",
"description": "mix path"
},
"String-trans": {
"prefix": "lv:trans",
"body": "{{ trans('$1') }}",
"description": "trans"
},
"URL-action": {
"prefix": "lv:action",
"body": "{{ action('${1:ControllerName}', [${2:'id'=>1}]) }}",
"description": "URL-action"
},
"URL-secure-asset": {
"prefix": "lv:secure-asset",
"body": "{{ secure_asset('$1', ${2:\\$title}, ${3:\\$attributes=[]}) }}",
"description": "URL-secure-asset"
},
"URL-url": {
"prefix": "lv:url",
"body": "{{ url('${1:url}', [$2]) }}",
"description": "URL-url"
},
"URL-asset": {
"prefix": "lv:asset",
"body": "{{ asset('$1') }}",
"description": "URL-asset"
},
"URL-route": {
"prefix": "lv:route",
"body": "{{ route('${1:routeName}', [${2:'id'=>1}]) }}",
"description": "URL-route"
},
"Form-csrf-field": {
"prefix": "lv:csrf-field",
"body": "{{ csrf_field() }}",
"description": "CSRF hidden field"
},
"csrf-token": {
"prefix": "lv:csrf-token",
"body": "{{ csrf_token() }}",
"description": "CSRF token"
},
"Paginate-links": {
"prefix": "lv:pagination-links",
"body": "{{ \\$${1:collection}->links() }}",
"description": "pagination links"
}
}
17 changes: 17 additions & 0 deletions snippets/frameworks/blade/livewire.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"livewireStyles": {
"prefix": "livewire:styles",
"body": "@livewireStyles",
"description": "Livewire Styles directive"
},
"livewireScripts": {
"prefix": "livewire:scripts",
"body": "@livewireScripts",
"description": "Livewire Scripts directive"
},
"livewire-component": {
"prefix": "livewire:component",
"body": "@livewire('${1:component}', ['${2:user}' => \\$${3:user}]${4:, key(\\$$3->id)})",
"description": "Livewire nesting components"
}
}
Loading

0 comments on commit b6a8d1e

Please sign in to comment.