onecentlin / laravel-blade-snippets-vscode Goto Github PK
View Code? Open in Web Editor NEWLaravel blade snippets and syntax highlight support for Visual Studio Code
License: MIT License
Laravel blade snippets and syntax highlight support for Visual Studio Code
License: MIT License
OK when I write a blank blade set up as below
@extends('layouts.main')
@section('content')
@stop
Then on saving it inlines the code as follows.
@extends('layouts.main') @section('content') @stop
And when putting html code within the content section it still only inlines the top part eg below:
@extends('layouts.main') @section('content')
<div>
</div>
@stop`
Is there a setting or config needs sorting or is this a conflict etc
When I copied the given code to my User Settings it didn't work.
"emmet.syntaxProfiles": {
"blade": "html"
},
However, the code below seems to activate Emmet for Blade again.
"emmet.includeLanguages": {
"blade": "html"
},
Thanks for a great extension!
Right now the blade directives appear in the same color as HTML tags. It would be good to visually differentiate blade directives from tags, my suggestion would be to make them the same color that functions are defined as in the syntax theme.
My guess is that the blade grammar is setting blade directives as tags, instead of functions?
Any suggestions? (I haven't figured out how to manually override the setting in user settings, if that is even at all possible.)
Great plugin I found it really useful, but I do notice that formatting on save or any other type of formatting of the HTML markup doesn't occur as it does in a normal .html
file.
Is it possible to have the formatting work in blade templates?
I hope this issue will be fix soon.. Blade file doesn't work like HTML file that has javascript autocompletion inside script tag. If I change blade to HTML file, javascript autocompletion will work but then syntax highlight from Laravel Snippet will stop to work.
In the Laravel docs, and even in the auto-generated views from the command php artisan make:auth
some - not all - blade directives such as @if
, @if @else
, @foreach
, @forelse
have a space right before the opening parenthesis.
@if($condition)
@if ($condition)
I know this is just a very minor issue but I think you should apply this to the snippets for the sake of consistency with the framework.
Hello, and thanks for this package!
I am having some issues with formatting of @section, as per the attached image. Any ideas?
Is it possible to turn off the syntax highlighting and keep the snippets?
I use another Extension that works better for blade highlighting but this extension just overwrites the syntax highlighting if it's installed so I can't use the snippets which are great.
Thanks
Could we get an option to disable blade comments? I never use blade comments and prefer to use html comments in my blade files
I guess this is a very special file because it doesn't have your average blade tags.. but it ships with Laravel and a lot of people use it.. Right now if I add
"files.associations": {
"*.blade.php": "html"
}
as you suggested in the thread about blade formatting, then it makes everything white and no longer highlights the blade functions
@setup
require __DIR__.'/vendor/autoload.php';
$dotenv = new Dotenv\Dotenv(__DIR__);
try {
$dotenv->load();
$dotenv->required(['DEPLOY_SERVER', 'DEPLOY_REPOSITORY', 'DEPLOY_PATH'])->notEmpty();
} catch ( Exception $e ) {
echo $e->getMessage();
}
$server = getenv('DEPLOY_SERVER');
$repo = getenv('DEPLOY_REPOSITORY');
$path = getenv('DEPLOY_PATH');
$branch = getenv('DEPLOY_BRANCH');
$slack = getenv('DEPLOY_SLACK_WEBHOOK');
if ( substr($path, 0, 1) !== '/' ) throw new Exception('Careful - your deployment path does not begin with /');
$date = ( new DateTime )->format('YmdHis');
$env = isset($env) ? $env : "production";
$branch = isset($branch) ? $branch : "master";
$path = rtrim($path, '/');
$release = $path.'/'.$date;
@endsetup
@servers(['web' => $server])
@task('init')
if [ ! -d {{ $path }}/current ]; then
cd {{ $path }}
git clone {{ $repo }} --branch={{ $branch }} --depth=1 -q {{ $release }}
#echo "git clone {{ $repo }} --branch={{ $branch }} --depth=1 -q {{ $release }}"
echo "Repository cloned"
mv {{ $release }}/storage {{ $path }}/storage
ln -s {{ $path }}/storage {{ $release }}/storage
ln -s {{ $path }}/storage/public {{ $release }}/public/storage
echo "Storage directory set up"
cp {{ $release }}/.env.live {{ $path }}/.env
ln -s {{ $path }}/.env {{ $release }}/.env
echo "Environment file set up"
rm -rf {{ $release }}
echo "Deployment path initialised. Run 'envoy run deploy' now."
else
echo "Deployment path already initialised (current symlink exists)!"
fi
@endtask
@story('deploy')
deployment_start
deployment_links
deployment_composer
{{--deployment_migrate--}}
deployment_cache
{{--deployment_optimize--}}
deployment_finish
deployment_option_cleanup
@endstory
...
I also really can't get the blade formatting to work at all, it makes my Envoy file wrap on a single line even though I'm using your settings you also posted in that other thread
Hi, thanks for your plugin!
i'm wondering tho, why this happens: ( the blue highlights )
its the default Dark+ theme. ( and happens with most themes )
it has successfully detected is a blade template:
code:
<style type="text/css">
@php
if( is_front_page() ) {
$service_page_id = App\monfortur_get_option( 'monfortur_options_page_services' );
$image_id = get_post_meta( $service_page_id, 'services_box_service_banner_id', true );
$preloader = "";
$image_large = "";
$image_full = "";
if( ! empty( $image_id ) ) {
$preloader = wp_get_attachment_image_src( $image_id, 'preloader' );
if( $preloader ){
$preloader = base64_encode( file_get_contents( $preloader[0] ) );
}
Commenting with CTRL + / keeps adding html comment {{-- --}}
instead of javascript comment //
And also after creating div tag and press enter, the cursor didn't automatically adjust to create newline between opening and closing tag. I mean it should be:
<div>
|
</div>
not
<div>
|</div>
please fix this soon, thanks!
Your extension auto formats my blade documents. I have the following block of code:
<input id="username" name="username" type="text" value="{{ old('username') }}">
@if ($errors->has('username'))
<div class="error">Username Error here</div>
@endif
And when I save the document or run "Format Document" it formats it to this:
<input id="username" name="username" type="text" value="{{ old('username') }}"> @if ($errors->has('username'))
<div class="error">Username Error here</div>
@endif
Really, really annoying. It is definitely this extension doing it to because if I disable all extensions it does not format the document. But if I then enable ONLY this extension, it formats the document.
How do I turn off this feature? Or how do I control the formatting rules? When I search in my settings for "laravel" I see zero settings to control this extension's features and behavior.
Also, kind of weird that It doesn't say anything about formatting on the extension page. If the extension is a "snippet" extension as the title implies maybe you should not add in hidden features like formatting that cannot be disabled.
Auto fomat will format code
<option value='{{$k}}'{{($k == $product->status)?" SELECTED":null}}>{{$v}}</option>
to
<option value='{{$k}}' {{($k==$ product->status)?" SELECTED":null}}>{{$v}}</option>
and
@extends('admin.layouts.master')
@section('css')
to
@extends('admin.layouts.master') @section('css')
Is there any way to fix this?
vscode version 1.18.1
In regular html pages if I type (below) and click enter while the cursor is in the middle of the tags
<p></p>
It will look like this:
<p>
(indented content)
</p>
With the latest vscode and all extensions, it seems this extension is not executing the indent and leaving me with this when doing the same in a page.blade.php file:
I noticed that there was another issue that covered the same topic but it was closed because it assumed the issue was related to VS Code due to PHP mode having the same problem. However, it looks like VS Code has fixed the problem with PHP mode and Auto Indent whereas this plugin still has the issue.
This is what happens in a normal HTML or PHP file:
<html>(cursor here)</html>
When I press enter it'll give me:
<html>
(cursor here)
</html>
However, while in a Blade file I'll get this:
<html>
(cursor here)</html>
The other issue that dealt with this is here: #2
When using your extension, the auto indent feature does not work:
But when I switch the document language to HTML, it works again:
It's a rather small thing, but when you have to create a lot of elements this get's pretty annoying.
Although I don't think this makes any difference, but I also included this in my settings:
"emmet.syntaxProfiles": {
"blade": "html"
},
I file this issue here rather than in the VS Code main repo, as the indentation works once I switch to HTML. I'm sorry if I'm mistaken.
If you need any more information, just tell me.
I have been building blade projects in vscode did not have an issue until a few weeks ago. I made one issue and was basically ignored after a few responses.
Below I have a link of my issue with the vscode team who shows screenshots and instructions on your extensions (as well as all blade extensions) on how to fix the formatting issue.
This is not an auto indent or emmet issue, they have laid out requirements needed for the auto indent formatting that all the blade extensions are not currently following, so I am making this issue in hopes that you can look and figure out how to fix this.
As of right now working in blade with the latest version of the stable and the insider build of vscode is not possible as it has 0 of the functionalities this extension is suppose to do.
HTML autocomplete doesn't work in blade files. Is it possible to fix it?
https://code.visualstudio.com/Docs/languages/html
For example: <a
should give me <a href="">
I may be missing a feature, but my HTML highlighting seems to be gone.
Is there a way to see open and closing brackets on a tag similar to how the .html files work?
Emmet does not work in blade using the "Laravel Blade Snippets" extension, even after adding the following configuration:
"emmet.syntaxProfiles": {
"blade": "html"
},
It would be nice if tag matching worked, because every time I need to match a opening div
with a closing div
I need to switch to html mode.
Currently if you put the cursor over a div
tag it selects all of the div
's
If I am not mistaken this could be included to support this https://github.com/Microsoft/vscode-html-languageservice
Currently Blade Snippets VsCode Auto-format function turns this code:
{!! Form::label('nome', 'Nome:') !!}
{!! Form::text('nome', null, array('class' => 'form-control', 'style' => 'max-width:400px')) !!}
Into this:
{!! Form::label('nome', 'Nome:') !!} {!! Form::text('nome', null, array('class' => 'form-control', 'style' => 'max-width:400px'))
!!}
It would be great if it would keep each {!! Form: * in its own line.
Thanks in advance
If I use then the php inside just gets ignored when I format the document
Using cmd-/ to comment inside the tags however applies the wrong comment syntax
If I use @php @endphp, the wrong comment syntax are also applied, and if I use the format document it removes all lines breaks and puts everything on one line basically
when i change syntax to html it's work correctly but when i change back to laravel blade indent not working. i add emmet syntaxprofile already.
how to solve this issue?
THX
@inputRadio([
'name' => 'tab',
'value' => $posting->url ? 'url' : ($posting->contact ? 'existing' : 'new'),
'name' => 'tab',
'items' => $items,
])
Or here another example:
@inputSelect([
'label' => 'Ansprechpartner',
'name' => 'id',
'value' => $posting->contact->id ?? null,
'items' => $contacts->map(function($item) {
return [
'value' => $item->id,
'label' => $item->name,
];
}),
'required' => true,
])
Just a minor snippet suggestion to add:
@lang('messages.name')
The following code that works:
<a href="{{ url("invoices/{$invoice->id}/mailable/invoice") }}" class="dropdown-item">Verify email to be sent</a>
is being replaced by
<a href="{{ url(" invoices/{$invoice->id}/mailable/invoice") }}" class="dropdown-item">Verify email to be sent</a>
Notice the space added in the URL, which breaks the URLs.
@can
, @elsecan
and @endcan
(since 5.1)
@cannot
, @elsecannot
and @endcannot
(since 5.3)
@section('sometag', Form::model($model, ['route' => array_merge(['abc', $model->id], request()->query()), 'method' => 'put', 'files' => true]))
How do you use space when formatting the document? it always use tab, even if the settings below is set to space
@onecentlin Thank you for your plugin. It's very helpful.
I use Roots/Sage WordPress Template.
The Html tag has different color.
How to fix it? Thank you.
i just updated the extension to v1.14.0 and I am getting below error in my vscode
"The Blade Language Server server crashed 5 times in last 3 minutes. The server will not be restarted."
Error output
Error: Cannot find module '/Users/badalsurana/.vscode/extensions/onecentlin.laravel-blade-1.14.0/server/out/htmlServerMain.js' at Function.Module._resolveFilename (module.js:470:15) at Function.Module._load (module.js:418:25) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at Server.<anonymous> (/Users/badalsurana/.vscode/extensions/onecentlin.laravel-blade-1.14.0/node_modules/vscode-languageclient/lib/utils/electronForkStart.js:110:9) at emitOne (events.js:96:13) at Server.emit (events.js:191:7) at Pipe.onconnection (net.js:1486:8)
[Error - 3:10:42 PM] Connection to server got closed. Server will not be restarted.
With the new VSCode update, things seems to be pretty broken with this extension right now as this screenshot suggests :
Here's the same screenshot with the PHP syntax enabled :
Not only does this shows how the syntax is affected, this also means that other utilities are broken as well : snippets and autocompletion is also broken when you are located in the broken part of the syntax.
Take note that this screenshot tries to show that the above snippet works, while the one in yellow show No suggestions
.
VSCode version: 1.12.1
Extension version: 1.17.0
Detail:
Cmd + / give me this (4 spaces inside comment block)
{{-- --}}
Anyway, b:comment give me the correct format.
Expected behavior:
It should give me this (2 spaces inside comment block)
{{-- --}}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.