Comments (3)
I would also like to see proper formatting of Blade directives within script tags, or at least an "ignore" feature within script tags so that it doesn't automatically format it as garbage (similar to something like prettiers <!-- prettier-ignore -->
). One huge use case of blade is passing data to javascript to create reactive layouts.
For instance, the following code:
var order = @json($array['item']->getOrder());
Gets formatted to:
var order = @json($array['item'] - > getOrder());
(notice the additional spaces)
This causes a parse error during blade compilation: Parse error: syntax error, unexpected '>' ...
This is only one small example, but the formatting errors only get worse the more complex the blade directives get.
from vscode-blade-formatter.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
from vscode-blade-formatter.
@yasinallana1
Fixed this behaviour on v0.7.8 (v1.11.1 on blade-formatter)
@push('scripts')
<script src="{{ asset('backend/plugins/dropzone/dropzone.min.js') }}"></script>
<script>
Dropzone.options.gallery = {
url: "...",
previewTemplate: $("#preview-template").html(),
dictDefaultMessage: "Drop files here or click to select",
addRemoveLinks: true,
uploadMultiple: true,
maxFilesize: 2,
filesizeBase: 1024,
acceptedFiles: "image/jpg,image/jpeg,image/png",
init: function() {
this.renderExistingServerFiles = function(files, fileUrls, response) {
for (const file in files) {
if (Object.hasOwnProperty.call(files, file)) {
const element = files[file];
this.files.push(element);
this.displayExistingFile(element, fileUrls[file], null, null, true);
this.emit("processing", element);
this.emit("complete", element);
}
}
this.emit("successmultiple", files, response, false);
}
@isset($item->images)
let files = [];
let fileUrls = [];
let response = { status:"success", fileHashes: [], imageIds: []};
@foreach ($item->images as $image)
@php
$imageUrl = asset('img/' . $image->image_hash);
$imagePath = public_path('img/' . $image->image_hash);
$imageMime = File::mimeType($imagePath);
$imageSize = File::size($imagePath);
$imageName = File::name($imagePath);
@endphp
var order = {{ @json($array['item']->getOrder()) }}
files.push({
processing: true,
accepted: true,
name: "{{ $imageName }}",
size: {{ $imageSize }},
type: '{{ $imageMime }}',
status: Dropzone.SUCCESS,});
fileUrls.push("{{ $imageUrl }}")
response.fileHashes.push("{{ $image->image_hash }}")
response.imageIds.push("{{ $image->id }}")
@endforeach
this.renderExistingServerFiles(files, fileUrls, response);
@endisset
},
}
</script>
@endpush
Now you can format directive and raw javascript mixed template.
var order = @json($array['item']->getOrder());
is also ok.
from vscode-blade-formatter.
Related Issues (20)
- [Formatting Bug]: @elsecan blade directive is ignored HOT 1
- [Formatting Bug]: not adjusting my text in text format HOT 1
- [Formatting Bug]: Added spaces around hypen even when string in quotes HOT 1
- [Formatting Bug]: HOT 2
- [Formatting Bug]: HOT 2
- [Formatting Bug]: Showing red color
- [Bug]: After the installation, blade files lose syntax highlight! HOT 5
- [Formatting Bug]: HOT 3
- [Formatting Bug]: Components params are broken after formatting - since v0.23 HOT 2
- [Formatting Bug]: Formatter broken php code inside @php @endphp blade tags HOT 1
- [Formatting Bug]: spaces contained in string are broken up when wrapping text. HOT 2
- [Formatting Bug]: The extension ignores, some properties of the main configuration file HOT 2
- [Feature]: Edge Template Support HOT 1
- [Formatting Bug]: Custom directive incorrectly indented HOT 1
- [Bug]: HTML syntax highlighting and html suggestions in .blade.php is gone when I install this extension HOT 3
- [Bug]: Problem with syntax HOT 1
- [Bug]: Extension doesn't work when installed onto a cPanel account
- [Formatting Bug]: PHP new with variable name from associative array
- [Formatting Bug]: Multiplying `values` attribute!
- [Feature]: Exclude path by default
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-blade-formatter.