An opinionated blade template formatter for Laravel that respects readability

Overview

npm version GitHub Workflow Status npm NPM

blade-formatter

An opinionated blade template formatter for Laravel that respects readability

blade-formatter

Online Demo

Features

  • Automatically Indents markup inside directives

    blade-formatter-indent

  • Automatically add spacing to blade templating markers

    blade-formatter-spacing

  • PHP 8 support (null safe operator, named arguments) 🐘

    blade-formatter-php8

  • PSR-2 support (format inside directives)

    blade-formatter-format-in-directive

Example

Input

@extends('frontend.layouts.app')
@section('title') foo
@endsection
@section('content')
<section id="content">
<div class="container mod-users-pd-h">
    <div class="pf-user-header">
    <div></div>
    <p>@lang('users.index')</p>
    </div>
        <div class="pf-users-branch">
            <ul class="pf-users-branch__list">
                @foreach($users as $user)
        <li>
            <img src="{{ asset('img/frontend/icon/branch-arrow.svg') }}" alt="branch_arrow">
            {{ link_to_route("frontend.users.user.show",$users["name"],$users['_id']) }}
        </li>
        @endforeach
      </ul>
      <div class="pf-users-branch__btn">
      @can('create', App\Models\User::class)
            {!! link_to_route("frontend.users.user.create",__('users.create'),[1,2,3],['class' => 'btn']) !!}
            @endcan
        </div>
  </div>
    </div>
</section>
@endsection
@section('footer')
@stop

Output

@extends('frontend.layouts.app')
@section('title') foo
@endsection
@section('content')
    <section id="content">
        <div class="container mod-users-pd-h">
            <div class="pf-user-header">
                <div></div>
                <p>@lang('users.index')</p>
            </div>
            <div class="pf-users-branch">
                <ul class="pf-users-branch__list">
                    @foreach ($users as $user)
                        <li>
                            <img src="{{ asset('img/frontend/icon/branch-arrow.svg') }}" alt="branch_arrow">
                            {{ link_to_route('frontend.users.user.show', $users['name'], $users['_id']) }}
                        </li>
                    @endforeach
                </ul>
                <div class="pf-users-branch__btn">
                    @can('create', App\Models\User::class)
                        {!! link_to_route('frontend.users.user.create', __('users.create'), [1, 2, 3], ['class' => 'btn']) !!}
                    @endcan
                </div>
            </div>
        </div>
    </section>
@endsection
@section('footer')
@stop

Installation

$ npm install --save-dev blade-formatter
$ node_modules/.bin/blade-formatter -h

yarn

$ yarn add --dev blade-formatter

global

$ npm install -g blade-formatter
$ yarn global add blade-formatter

docker

$ docker run -it -v $(pwd):/app -w /app shufo/blade-formatter resources/**/*.blade.php

Usage

  • Basic
# This outputs formatted result to stdout
$ blade-formatter resources/**/*.blade.php
$ blade-formatter resources/layouts/app.blade.php
  • Check if template is formatted or not (makes no change)
$ blade-formatter app/** -d -c
Check formatting...
app/index.blade.php

Above file(s) are formattable. Forgot to run formatter? Use --write option to overwrite.
$ echo $?
1
  • Format files and overwrite
$ blade-formatter --write resources/**/*.blade.php
  • Show diffs
$ blade-formatter -c -d resources/**/*.blade.php

Options

option description default
--check-formatted, -c Only check files are formatted or not. Exit with exit code 1 if files are not formatted false
--write, --w Write to file false
--diff, -d Show differences false
--indent-size, -i Indentation size 4
--wrap-line-length, --wrap The length of line wrap size 120
--wrap-attributes, --wrap-atts The way to wrap attributes. [auto|force|force-aligned|force-expand-multiline|aligned-multiple|preserve|preserve-aligned] auto
--end-with-newline, -e End output with newline true
--stdin format code provided on <STDIN> false
--help, -h Show help
--version, -v Show version

Ignore Files

To ignore specific file, put .bladeignore to your repository root will blade-formatter treat it as ignored files.

e.g.

resources/views/users/index.blade.php
resources/views/products/*
resources/views/books/**/*

API

You can use blade formatter by API as well.

require = require('esm')(module);
const { BladeFormatter } = require('blade-formatter');

const input = `
<html>
  <body>
    <p>foo</p>
  </body>
</html>
`;

const options = {
  indentSize: 2,
};

new BladeFormatter(options).format(input).then((formatted) => {
  console.log(formatted);
});

Extensions

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

LICENSE

MIT

Troubleshoot

  • If you encounter the error until installation like below
$ npm install -g blade-formatter
~~
current user ("nobody") does not have permission to access the dev dir
~~

Try set global user as root

$ npm -g config set user root

TODO

  • Editable custom directives
  • @for directive support
  • ignore formatting in blade comment

Contributors

shufo
Shuhei Hayashibara
slovenianGooner
SlovenianGooner
schelmo
Schelmo
yaegassy
Yaegassy
dianfishekqi
Dian Fishekqi
jtanaka
Jumpei Tanaka
Comments
  • feat: x-data and x-init alpine attribute support

    feat: x-data and x-init alpine attribute support

    Description

    Hello @shufo , this PR adds support for formatting x-data and x-init attributes for those using alpine.

    Screenshot

    image

    There is more work to be done in order to preserve the attribute offset.

    opened by dianfishekqi 9
  • Bump jest from 24.9.0 to 25.1.0

    Bump jest from 24.9.0 to 25.1.0

    Bumps jest from 24.9.0 to 25.1.0.

    Release notes

    Sourced from jest's releases.

    25.1.0

    Blog post: https://jestjs.io/blog/2020/01/21/jest-25

    Features

    • [babel-plugin-jest-hoist] Show codeframe on static hoisting issues (#8865)
    • [babel-plugin-jest-hoist] Add BigInt to WHITELISTED_IDENTIFIERS (#8382)
    • [babel-preset-jest] Add @babel/plugin-syntax-bigint (#8382)
    • [expect] Add BigInt support to toBeGreaterThan, toBeGreaterThanOrEqual, toBeLessThan and toBeLessThanOrEqual (#8382)
    • [expect, jest-matcher-utils] Display change counts in annotation lines (#9035)
    • [expect, jest-snapshot] Support custom inline snapshot matchers (#9278)
    • [jest-config] Throw the full error message and stack when a Jest preset is missing a dependency (#8924)
    • [jest-config] [BREAKING] Set default display name color based on runner (#8689)
    • [jest-config] Merge preset globals with project globals (#9027)
    • [jest-config] Support .cjs config files (#9291)
    • [jest-config] [BREAKING] Support .mjs config files (#9431)
    • [jest-core] Support reporters as default exports (#9161)
    • [jest-core] Support --findRelatedTests paths case insensitivity on Windows (#8900)
    • [jest-diff] Add options for colors and symbols (#8841)
    • [jest-diff] [BREAKING] Export as ECMAScript module (#8873)
    • [jest-diff] Add includeChangeCounts and rename Indicator options (#8881)
    • [jest-diff] Add changeColor and patchColor options (#8911)
    • [jest-diff] Add trailingSpaceFormatter option and replace cyan with commonColor (#8927)
    • [jest-diff] Add firstOrLastEmptyLineReplacement option and export 3 diffLines functions (#8955)
    • [jest-environment] Add optional getVmContext next to runScript (#9252 & #9428)
    • [jest-environment-jsdom] Add fakeTimersLolex (#8925)
    • [jest-environment-node] Add fakeTimersLolex (#8925)
    • [jest-environment-node] Add queueMicrotask (#9140)
    • [jest-environment-node] Implement getVmContext (#9252 & #9428)
    • [@jest/fake-timers] Add Lolex as implementation of fake timers (#8897)
    • [jest-get-type] Add BigInt support. (#8382)
    • [jest-matcher-utils] Add BigInt support to ensureNumbers ensureActualIsNumber, ensureExpectedIsNumber (#8382)
    • [jest-matcher-utils] Ignore highlighting matched asymmetricMatcher in diffs (#9257)
    • [jest-reporters] Export utils for path formatting (#9162)
    • [jest-reporters] Provides global coverage thresholds as watermarks for istanbul (#9416)
    • [jest-runner] Warn if a worker had to be force exited (#8206)
    • [jest-runtime] [BREAKING] Do not export ScriptTransformer - it can be imported from @jest/transform instead (#9256)
    • [jest-runtime] Use JestEnvironment.getVmContext and vm.compileFunction if available to avoid the module wrapper (#9252 & #9428)
    • [jest-snapshot] Display change counts in annotation lines (#8982)
    • [jest-snapshot] [BREAKING] Improve report when the matcher has properties (#9104)
    • [jest-snapshot] Improve colors when snapshots are updatable (#9132)
    • [jest-snapshot] Ignore indentation for most serialized objects (#9203)
    • [jest-transform] Create createTranspilingRequire function for easy transpiling modules (#9194)
    • [jest-transform] [BREAKING] Return transformed code as a string, do not wrap in vm.Script (#9253)
    • [@jest/test-result] Create method to create empty TestResult (#8867)
    • [jest-worker] [BREAKING] Return a promise from end(), resolving with the information whether workers exited gracefully (#8206)
    • [jest-reporters] Transform file paths into hyperlinks (#8980)

    Fixes

    ... (truncated)
    Changelog

    Sourced from jest's changelog.

    25.1.0

    Features

    • [babel-plugin-jest-hoist] Show codeframe on static hoisting issues (#8865)
    • [babel-plugin-jest-hoist] Add BigInt to WHITELISTED_IDENTIFIERS (#8382)
    • [babel-preset-jest] Add @babel/plugin-syntax-bigint (#8382)
    • [expect] Add BigInt support to toBeGreaterThan, toBeGreaterThanOrEqual, toBeLessThan and toBeLessThanOrEqual (#8382)
    • [expect, jest-matcher-utils] Display change counts in annotation lines (#9035)
    • [expect, jest-snapshot] Support custom inline snapshot matchers (#9278)
    • [jest-config] Throw the full error message and stack when a Jest preset is missing a dependency (#8924)
    • [jest-config] [BREAKING] Set default display name color based on runner (#8689)
    • [jest-config] Merge preset globals with project globals (#9027)
    • [jest-config] Support .cjs config files (#9291)
    • [jest-config] [BREAKING] Support .mjs config files (#9431)
    • [jest-core] Support reporters as default exports (#9161)
    • [jest-core] Support --findRelatedTests paths case insensitivity on Windows (#8900)
    • [jest-diff] Add options for colors and symbols (#8841)
    • [jest-diff] [BREAKING] Export as ECMAScript module (#8873)
    • [jest-diff] Add includeChangeCounts and rename Indicator options (#8881)
    • [jest-diff] Add changeColor and patchColor options (#8911)
    • [jest-diff] Add trailingSpaceFormatter option and replace cyan with commonColor (#8927)
    • [jest-diff] Add firstOrLastEmptyLineReplacement option and export 3 diffLines functions (#8955)
    • [jest-environment] Add optional getVmContext next to runScript (#9252 & #9428)
    • [jest-environment-jsdom] Add fakeTimersLolex (#8925)
    • [jest-environment-node] Add fakeTimersLolex (#8925)
    • [jest-environment-node] Add queueMicrotask (#9140)
    • [jest-environment-node] Implement getVmContext (#9252 & #9428)
    • [@jest/fake-timers] Add Lolex as implementation of fake timers (#8897)
    • [jest-get-type] Add BigInt support. (#8382)
    • [jest-matcher-utils] Add BigInt support to ensureNumbers ensureActualIsNumber, ensureExpectedIsNumber (#8382)
    • [jest-matcher-utils] Ignore highlighting matched asymmetricMatcher in diffs (#9257)
    • [jest-reporters] Export utils for path formatting (#9162)
    • [jest-reporters] Provides global coverage thresholds as watermarks for istanbul (#9416)
    • [jest-runner] Warn if a worker had to be force exited (#8206)
    • [jest-runtime] [BREAKING] Do not export ScriptTransformer - it can be imported from @jest/transform instead (#9256)
    • [jest-runtime] Use JestEnvironment.getVmContext and vm.compileFunction if available to avoid the module wrapper (#9252 & #9428)
    • [jest-snapshot] Display change counts in annotation lines (#8982)
    • [jest-snapshot] [BREAKING] Improve report when the matcher has properties (#9104)
    • [jest-snapshot] Improve colors when snapshots are updatable (#9132)
    • [jest-snapshot] Ignore indentation for most serialized objects (#9203)
    • [jest-transform] Create createTranspilingRequire function for easy transpiling modules (#9194)
    • [jest-transform] [BREAKING] Return transformed code as a string, do not wrap in vm.Script (#9253)
    • [@jest/test-result] Create method to create empty TestResult (#8867)
    • [jest-worker] [BREAKING] Return a promise from end(), resolving with the information whether workers exited gracefully (#8206)
    • [jest-reporters] Transform file paths into hyperlinks (#8980)

    Fixes

    • [expect] Display expectedDiff more carefully in toBeCloseTo (#8389)
    ... (truncated)
    Commits
    • 5dcc480 Release 25.1.0
    • 170eee1 fix: expose vm context directly from test envs (#9428)
    • e818dca feat: add support for .mjs config (#9431)
    • 8236779 Fix: Prevent maintaining RegExp state between multiple tests (#9289)
    • f19adb1 chore: bump babel (#9427)
    • 2ece4f9 Do not highlight matched asymmetricMatcher in diffs (#9257)
    • 2839036 chore: sort entries in changelog
    • 7ee717d Fix pretty-format to respect displayName on forwardRef. (#9422)
    • abaea37 Normalize --findRelatedTests paths on win32 platforms (#8961)
    • c8c4c4e jest-snapshot: Fix regression in diff for jest-snapshot-seriali… (#9419)
    • Additional commits viewable in compare view
    Maintainer changes

    This version was pushed to npm by davidzilburg, a new releaser for jest since your current version.


    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Note: This repo was added to Dependabot recently, so you'll receive a maximum of 5 PRs for your first few update runs. Once an update run creates fewer than 5 PRs we'll remove that limit.

    You can always request more updates by clicking Bump now in your Dependabot dashboard.

    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language
    • @dependabot badge me will comment on this PR with code to add a "Dependabot enabled" badge to your readme

    Additionally, you can set the following in your Dependabot dashboard:

    • Update frequency (including time of day and day of week)
    • Pull request limits (per update run and/or open at any time)
    • Out-of-range updates (receive only lockfile updates, if desired)
    • Security updates (receive only security updates, if desired)
    dependencies 
    opened by dependabot-preview[bot] 8
  • Laravel @php Helper

    Laravel @php Helper

    Instead of just removing code like @php $bg = rand(1, 13); $bgchange = $bg.".jpg"; @endphp from a view wouldn't it be better to just throw a warning that using @php tag in views is frowned upon to avoid breaking views?

    opened by HDVinnie 8
  • @lang() Issues

    @lang() Issues

    Expected Behavior

    Not to add a space in @lang('torrent.stream-optimized')

    Current Behavior

                                @if ($torrent->stream == 1)
                                    <span class='badge-extra text-bold'>
                                        <i class='{{ config('other.font-awesome') }} fa-play text-red' data-toggle='tooltip'
    -                                        title='' data-original-title='@lang('torrent.stream-optimized')'></i>
    +                                        title='' data-original-title='@lang(' torrent.stream-optimized')'></i>
                                    </span>
                                @endif
    

    Possible Solution

    No Idea.

    bug 
    opened by HDVinnie 7
  • Combination of Blade's block level directives and PHP's alternative foreach syntax make formatter add indent forever

    Combination of Blade's block level directives and PHP's alternative foreach syntax make formatter add indent forever

    Expected Behavior

    I would expect the formatter to not add indentation on each format.

    Current Behavior

    When formatting a document which is wrapped in a block-level directive like @section(''), using other block-level Blade directives like @if and @foreach inside an PHP alternative style foreach block cause the formatter to keep adding indentation on each format.

    Steps to Reproduce

    1. Format the following code with blade-formatter 1.11.9:
    @section('section')
    <?php
        foreach ($foos as $foo):
    ?>
        @if($foo)
            <div><?= $foo ?></div>
        @endif
    <?php endforeach; ?>
    @endsection
    
    1. Observe that the output is the following. Notice the mismatched indentation on @if and @foreach
    @section('section')
        <?php foreach ($foos as $foo): ?>
        @if ($foo)
            <div><?= $foo ?></div>
            @endif
        <?php endforeach; ?>
    @endsection
    
    1. Format the same document again, and observe that the output is:
    @section('section')
        <?php foreach ($foos as $foo): ?>
        @if ($foo)
            <div><?= $foo ?></div>
                @endif
            <?php endforeach; ?>
    @endsection
    
    1. Format again:
    @section('section')
        <?php foreach ($foos as $foo): ?>
        @if ($foo)
            <div><?= $foo ?></div>
                    @endif
                <?php endforeach; ?>
    @endsection
    
    1. And a few more times:
    @section('section')
        <?php foreach ($foos as $foo): ?>
        @if ($foo)
            <div><?= $foo ?></div>
                                                    @endif
                                                <?php endforeach; ?>
    @endsection
    

    Here's a gif:

    RfVFaE6M6k

    bug 
    opened by wb-joona 6
  • @if in html class occurs error

    @if in html class occurs error

    Expected Behavior

    @if (count($topics))
      <ul class="list-group border-0">
        @foreach ($topics as $topic)
          <li class="list-group-item border-right-0 border-left-0 @if($loop->first) border-top-0 @endif"></li>
        @endforeach
      </ul>
    @endif
    

    Current Behavior

    @if (count($topics))
      <ul class="list-group border-0">
        @foreach ($topics as $topic)
          <li class="list-group-item border-right-0 border-left-0 <beautify start=" @if " exp=" ^^^$loop->first^^^">
            border-top-0
        @endif"></li>
    @endforeach
    </ul>
    @endif
    
    bug 
    opened by keane0811 6
  • Incorrect @php block indentation of if/elseif/else statements

    Incorrect @php block indentation of if/elseif/else statements

    Context (Environment)

    I've noticed incorrect indentation when using an if/elseif/else statement inside a @php block. The code inside the block still works fine, it's just the else ends up indented incorrectly.

    Current Behavior

    This is how the code ends up indented:

                                <td>
                                    @php
                                        if ($condition1) {
                                            $var1 = '...';
                                            $var2 = '...';
                                        } elseif ($condition2) {
                                            $var1 = '...';
                                            $var2 = '...';
        } else {
            $var1 = '...';
            $var2 = '...';
                                        }
                                    @endphp
    
                                    <span>{{ $var1 . $var2 }}</span>
                                </td>
    

    Expected Behavior

    This is how I would expect the code to be indented:

                                <td>
                                    @php
                                        if ($condition1) {
                                            $var1 = '...';
                                            $var2 = '...';
                                        } elseif ($condition2) {
                                            $var1 = '...';
                                            $var2 = '...';
                                        } else {
                                            $var1 = '...';
                                            $var2 = '...';
                                        }
                                    @endphp
    
                                    <span>{{ $var1 . $var2 }}</span>
                                </td>
    

    Detailed Description

    I've tried 1.4.19 and 1.4.20 and this indentation occurs in both versions.

    Steps to Reproduce

    See examples above.

    opened by ziadoz 5
  • syntax error with @include

    syntax error with @include

    Laravel 9, PHP 8.1 #502 introduced a bug

    @include('livewire.cx.equipment-list-internal.account', ['account' => $account]) has been formatted as

    @include(
        'livewire.cx.equipment-list-internal.account', 
        ['account' => $account],
    )
    

    notice the last comma after ] and this throws syntax error, unexpected token ",", expecting ")"

    opened by G3z 5
  • Couldn't resolve parser

    Couldn't resolve parser "php" in local installation

    Context (Environment)

    We're trying to use blade-formatter in a Laravel 8 project on the latest MacOS but it can't resolve the PHP parser. It does work when installing globally but we'd rather have it locally if possible.

    Thanks for any help in advance!

    Current Behavior

    Every call results in the following error for every blade template checked

    {
      path: 'resources/views/xxx/show.blade.php',
      message: `Couldn't resolve parser "php"`,
      error: ConfigError$1: Couldn't resolve parser "php"
          at resolveParser$1 (/xxx/node_modules/blade-formatter/node_modules/prettier/index.js:12487:13)
          at normalize$1 (/xxx/node_modules/blade-formatter/node_modules/prettier/index.js:12582:18)
          at formatWithCursor$1 (xxx/node_modules/blade-formatter/node_modules/prettier/index.js:14265:46)
          at /xxx/node_modules/blade-formatter/node_modules/prettier/index.js:59304:12
          at Object.format (/xxx/node_modules/blade-formatter/node_modules/prettier/index.js:59324:12)
          at formatStringAsPhp (/xxx/node_modules/blade-formatter/src/util.js:42:19)
          at /xxx/node_modules/blade-formatter/src/util.js:133:16
          at String.replace (<anonymous>)
          at Function.replace (/xxx/node_modules/lodash/lodash.js:14608:48)
          at /xxx/node_modules/blade-formatter/src/util.js:132:9
    }
    

    Expected Behavior

    No error message :-)

    Steps to Reproduce

    1. npm install --save-dev blade-formatter
    2. node_modules/.bin/blade-formatter resources/**/*.blade.php
    opened by pboese 5
  • [Question]Do you have plans for stdin support?

    [Question]Do you have plans for stdin support?

    Thanks for this tool.

    I mainly use Vim.

    Support for stdin makes it easier and more convenient to integrate from other editors.

    Example:

    cat sample.blade.php | blade-formatter
    # or
    cat sample.blade.php | blade-formatter -
    

    Do you have a plan for stdin support?

    feature 
    opened by yaegassy 5
  • Unexpected <

    Unexpected <

    Im getting some odd errors in some views

    { path: 'resources/views/bonus/store.blade.php',
      message: 'Parse Error : syntax error, unexpected \'<\' on line 55\n\u001b[0m \u001b[90m 53 | \u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 54 | \u001b[39m                    \u001b[33m<\u001b[39m\u001b[33m?\u001b[39mphp \u001b[90m//@foreach ($downloadOptions as $d => $dO)\u001b[39m\u001b[0m\n\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 55 | \u001b[39m                        \u001b[33m<\u001b[39m\u001b[33mtr\u001b[39m\u001b[33m>\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m    | \u001b[39m                       \u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 56 | \u001b[39m                            \u001b[33m<\u001b[39m\u001b[33mtd\u001b[39m\u001b[33m>\u001b[39m\u001b[33m<\u001b[39m\u001b[33m?\u001b[39mphp  $dO[\u001b[32m\'description\'\u001b[39m]  \u001b[33m?\u001b[39m\u001b[33m>\u001b[39m\u001b[33m<\u001b[39m\u001b[33m/\u001b[39m\u001b[33mtd\u001b[39m\u001b[33m>\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 57 | \u001b[39m                            \u001b[33m<\u001b[39m\u001b[33mtd\u001b[39m\u001b[33m>\u001b[39m\u001b[33m<\u001b[39m\u001b[33m?\u001b[39mphp  $dO[\u001b[32m\'cost\'\u001b[39m]  \u001b[33m?\u001b[39m\u001b[33m>\u001b[39m\u001b[33m<\u001b[39m\u001b[33m/\u001b[39m\u001b[33mtd\u001b[39m\u001b[33m>\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 58 | \u001b[39m                            \u001b[33m<\u001b[39m\u001b[33mtd\u001b[39m\u001b[33m>\u001b[39m\u001b[0m',
      error: 
       { SyntaxError: Parse Error : syntax error, unexpected '<' on line 55
      53 | 
      54 |                     <?php //@foreach ($downloadOptions as $d => $dO)
    > 55 |                         <tr>
         |                        ^
      56 |                             <td><?php  $dO['description']  ?></td>
      57 |                             <td><?php  $dO['cost']  ?></td>
      58 |                             <td>
        at parser.raiseError (/usr/lib/node_modules/blade-formatter/node_modules/php-parser/src/parser.js:319:17)
        at parser.error (/usr/lib/node_modules/blade-formatter/node_modules/php-parser/src/parser.js:364:15)
        at parser.read_expr_item (/usr/lib/node_modules/blade-formatter/node_modules/php-parser/src/parser/expr.js:446:12)
        at parser.read_expr (/usr/lib/node_modules/blade-formatter/node_modules/php-parser/src/parser/expr.js:12:19)
        at parser.read_statement (/usr/lib/node_modules/blade-formatter/node_modules/php-parser/src/parser/statement.js:383:27)
        at parser.read_top_statement (/usr/lib/node_modules/blade-formatter/node_modules/php-parser/src/parser/statement.js:71:21)
        at parser.read_start (/usr/lib/node_modules/blade-formatter/node_modules/php-parser/src/parser/main.js:18:19)
        at parser.parse (/usr/lib/node_modules/blade-formatter/node_modules/php-parser/src/parser.js:277:23)
        at engine.parseCode (/usr/lib/node_modules/blade-formatter/node_modules/php-parser/src/index.js:167:22)
        at Object.parse (/usr/lib/node_modules/blade-formatter/node_modules/@prettier/plugin-php/src/parser.js:30:57)
         fileName: 'eval',
         loc: { start: [Object] },
         codeFrame: '\u001b[0m \u001b[90m 53 | \u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 54 | \u001b[39m                    \u001b[33m<\u001b[39m\u001b[33m?\u001b[39mphp \u001b[90m//@foreach ($downloadOptions as $d => $dO)\u001b[39m\u001b[0m\n\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 55 | \u001b[39m                        \u001b[33m<\u001b[39m\u001b[33mtr\u001b[39m\u001b[33m>\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m    | \u001b[39m                       \u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 56 | \u001b[39m                            \u001b[33m<\u001b[39m\u001b[33mtd\u001b[39m\u001b[33m>\u001b[39m\u001b[33m<\u001b[39m\u001b[33m?\u001b[39mphp  $dO[\u001b[32m\'description\'\u001b[39m]  \u001b[33m?\u001b[39m\u001b[33m>\u001b[39m\u001b[33m<\u001b[39m\u001b[33m/\u001b[39m\u001b[33mtd\u001b[39m\u001b[33m>\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 57 | \u001b[39m                            \u001b[33m<\u001b[39m\u001b[33mtd\u001b[39m\u001b[33m>\u001b[39m\u001b[33m<\u001b[39m\u001b[33m?\u001b[39mphp  $dO[\u001b[32m\'cost\'\u001b[39m]  \u001b[33m?\u001b[39m\u001b[33m>\u001b[39m\u001b[33m<\u001b[39m\u001b[33m/\u001b[39m\u001b[33mtd\u001b[39m\u001b[33m>\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 58 | \u001b[39m                            \u001b[33m<\u001b[39m\u001b[33mtd\u001b[39m\u001b[33m>\u001b[39m\u001b[0m' } }
    { path: 'resources/views/playlist/show.blade.php',
      message: 'Parse Error : syntax error, unexpected \'<\' on line 213\n\u001b[0m \u001b[90m 211 | \u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 212 | \u001b[39m\t\t\u001b[33m<\u001b[39m\u001b[33m?\u001b[39mphp \u001b[90m//<div class="block">\u001b[39m\u001b[0m\n\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 213 | \u001b[39m\t\t\t\t\u001b[33m<\u001b[39m\u001b[33mdiv\u001b[39m \u001b[36mclass\u001b[39m\u001b[33m=\u001b[39m\u001b[32m"row"\u001b[39m\u001b[33m>\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m     | \u001b[39m\t\t\t\u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 214 | \u001b[39m\t\t\t\t\t\u001b[33m<\u001b[39m\u001b[33mdiv\u001b[39m \u001b[36mclass\u001b[39m\u001b[33m=\u001b[39m\u001b[32m"col-xs-6 col-sm-4 col-md-3"\u001b[39m\u001b[33m>\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 215 | \u001b[39m\t\t\t\t\t\t\u001b[33m<\u001b[39m\u001b[33mdiv\u001b[39m \u001b[36mclass\u001b[39m\u001b[33m=\u001b[39m\u001b[32m"image-box text-center mb-20"\u001b[39m\u001b[33m>\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 216 | \u001b[39m\t\t\t\t\t\t\t\u001b[33m<\u001b[39m\u001b[33mdiv\u001b[39m \u001b[36mclass\u001b[39m\u001b[33m=\u001b[39m\u001b[32m"overlay-container"\u001b[39m\u001b[33m>\u001b[39m\u001b[0m',
    

    The < is not unexpected though.

    opened by HDVinnie 5
  • chore(deps): bump json5 from 1.0.1 to 1.0.2

    chore(deps): bump json5 from 1.0.1 to 1.0.2

    Bumps json5 from 1.0.1 to 1.0.2.

    Release notes

    Sourced from json5's releases.

    v1.0.2

    • Fix: Properties with the name __proto__ are added to objects and arrays. (#199) This also fixes a prototype pollution vulnerability reported by Jonathan Gregson! (#295). This has been backported to v1. (#298)
    Changelog

    Sourced from json5's changelog.

    Unreleased [code, diff]

    v2.2.3 [code, diff]

    v2.2.2 [code, diff]

    • Fix: Properties with the name __proto__ are added to objects and arrays. (#199) This also fixes a prototype pollution vulnerability reported by Jonathan Gregson! (#295).

    v2.2.1 [code, diff]

    • Fix: Removed dependence on minimist to patch CVE-2021-44906. (#266)

    v2.2.0 [code, diff]

    • New: Accurate and documented TypeScript declarations are now included. There is no need to install @types/json5. (#236, #244)

    v2.1.3 [code, diff]

    • Fix: An out of memory bug when parsing numbers has been fixed. (#228, #229)

    v2.1.2 [code, diff]

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • multibyte language support

    multibyte language support

    Context (Environment)

    I've tested this package while ago on a small project and I had problem with multibyte language in blade template files. It couldn't style multibyte languages and because of that the template could not get rendered.

    Current Behavior

    right now if you use multibyte languages, for example, Arabic or Persian in your code it formats code in a way that tags and PHP code could break.

    Expected Behavior

    It must support multibyte languages and format this text inside templates without breaking HTML or PHP codes.

    Steps to Reproduce

    create a blade template with UTF-8 char in the tags lets say <a href="#">لینک</a> and reformat it.

    opened by ariaieboy 2
  • fix(deps): update dependency vscode-textmate to v8

    fix(deps): update dependency vscode-textmate to v8

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | vscode-textmate | ^7.0.1 -> ^8.0.0 | age | adoption | passing | confidence |


    Configuration

    📅 Schedule: Branch creation - "every weekend" (UTC), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    dependencies 
    opened by renovate[bot] 1
  • chore(deps): update dependency fs-extra to v11

    chore(deps): update dependency fs-extra to v11

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | fs-extra | ^10.0.0 -> ^11.0.0 | age | adoption | passing | confidence |


    Release Notes

    jprichardson/node-fs-extra

    v11.1.0

    Compare Source

    • Re-add main field to package.json for better TypeScript compatibility (#​979, #​981)

    v11.0.0

    Compare Source

    Breaking Changes
    • Don't allow requiring fs-extra/lib/SOMETHING (switched to exports) (#​974)
    • Require Node v14.14+ (#​968, #​969)
    New Features
    • Add fs-extra/esm for ESM named export support; see docs for details (#​746, #​974)
    • Add promise support for fs.readv() (#​970)
    Bugfixes

    v10.1.0

    Compare Source

    • Warn if fs.realpath.native does not exist, instead of erroring (#​953)
    • Allow explicitly passing undefined options to move() (#​947, #​955)
    • Use process.emitWarning instead of console.warn (#​954)

    v10.0.1

    Compare Source

    • Add sideEffects: false to package.json (#​941)

    Configuration

    📅 Schedule: Branch creation - "every weekend" (UTC), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    dependencies 
    opened by renovate[bot] 1
  • line wrap on @set directive breaks the page

    line wrap on @set directive breaks the page

    The #542 issue is back again in v0.20.3.

    Current Behavior

    For this sample line:

    <p>
        <span>
            @set($num = $stat_leads->where('day', $day)->where('source', $source_key)->first()->total)
        </span>
    </p>
    

    the formatter does this:

    <p>
        <span>
            @set(
        $num = $stat_leads
            ->where('day', $day)
            ->where('source', $source_key)
            ->first()->total,
    )
        </span>
    </p>
    
    opened by formikaio 1
  • [Feature Request] Format classes in the @class directive

    [Feature Request] Format classes in the @class directive

    Could you please make the class sorting work with the @class directive?

    @class([
        'p-4',
        'font-bold' => $isActive,
        'text-gray-500' => !$isActive,
        'bg-red' => $hasError,
    ])
    
    opened by alexmandrikdev 3
Releases(v1.32.3)
Owner
Shuhei Hayashibara
Software Engineer
Shuhei Hayashibara
Blade Snip allows you to use parts of a blade template multiple times. Basically partials, but inline.

Blade Snip Blade Snip allows you to use parts of a blade template multiple times. Basically partials, but inline: <div class="products"> @snip('pr

Jack Sleight 18 Dec 4, 2022
Tiny Laravel worldwide currency formatter

Laravel Currency Formatter Tiny Laravel worldwide currency formatter Install composer require magarrent/laravel-currency-formatter Usage use Magarrent

Marc Garcia Torrent 17 Oct 5, 2022
Laravel Response Formatter

I created this package to make it easier to format the response from a controller. I have used this package in my projects and I hope you enjoy it!

aris wahyudiyanto 12 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
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
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
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
Snippets for blade template engine

Blade Snippets for Sublime Text Blade is a simple, yet powerful templating engine provided with Laravel PHP framework. These snippets works with blade

Alex Antonyuk 113 Jan 3, 2023
Laravel Segment is an opinionated, approach to integrating Segment into your Laravel application.

Laravel Segment Laravel Segment is an opinionated, approach to integrating Segment into your Laravel application. Installation You can install the pac

Octohook 13 May 16, 2022
A simple to use opinionated ERP package to work with Laravel

Laravel ERP A simple to use opinionated ERP package to work with Laravel Installation You can install the package via composer: composer require justs

Steve McDougall 16 Nov 30, 2022
An opinionated support package for Laravel, that provides flexible and reusable helper methods and traits for commonly used functionality.

Support An opinionated support package for Laravel, that provides flexible and reusable helper methods and traits for commonly used functionality. Ins

Ian Olson 3 Apr 14, 2021
An opinionated feature flags package for Laravel

This package provides an opinionated API for implementing feature flags in your Laravel applications. It supports application-wide features as well as model specific feature flags.

Ryan Chandler 157 Nov 24, 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
An opinionated package to create slugs for Eloquent models

Generate slugs when saving Eloquent models This package provides a trait that will generate a unique slug when saving any Eloquent model. $model = new

Spatie 1.1k Jan 4, 2023
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
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
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