vscode-blade-formatter

shufoMIT活跃维护

在 VSCode 里一键格式化 Laravel Blade 模板文件,统一缩进和排版,省去手动整理模板代码的麻烦。

An opinionated Blade file formatter for VSCode

v0.26.4发布于 2026-10-25 12:33 UTC5,261star43fork同步于 2026-11-10 23:37 UTC

怎么上手

由 README 提炼,执行前请确认
在 VSCode 扩展市场搜索并安装 shufo.vscode-blade-formatter;开发调试:npm install && npm run watch
硬件要求按 README 说明

README 未说明,作为 VSCode 扩展在本地编辑器进程内运行,无 GPU 或显存要求

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

VSCode 里的 Blade 模板格式化插件,自动整理 Laravel 视图缩进与空格

在 VSCode 里一键格式化 Laravel Blade 模板文件,统一缩进和排版,省去手动整理模板代码的麻烦。

核心能力

  • 自动缩进 Blade 指令内部的标记
  • 自动为 Blade 模板标记补齐空格
  • 支持 PHP 8 空安全运算符与命名参数
  • 支持 PSR-2 风格格式化指令内代码
  • 按 tailwind.config.js 自动排序 Tailwind 类名

容易踩的坑

项目级配置需在根目录放 .bladeformatterrc.json 或 .bladeformatterrc,否则只走编辑器设置;排除文件要另建 .bladeignore,使用 gitignore 语法;默认开启 PHP 语法检查,可用 noPhpSyntaxCheck 关闭

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.26.4
  1. v0.26.4最新正式版2026-10-25 · 2026-10-25 12:33 UTC

    0.26.4 (2026-10-25)

    Miscellaneous

    • 🤖 add dotenv to dev dependencies (e0de760)
    • 🤖 bump @vscode/vsce to v4 (cda41ed)
    • 🤖 bump action/checkout to v7 (ba58dd5)
    • 🤖 bump action/setup-node to v7 (c3b84a2)
    • 🤖 bump blade-formatter to 1.44.6 (4224a32)
    • 🤖 bump mocha to v12.x (f1ea37c)
    • 🤖 bump test-electron to 3.1.0 (cc4de7f)
    • 🤖 change vscodeignore pattern for esbuild (0269fa0)
    • 🤖 migrate from webpack to esbuild (da1a387)
    • 🤖 migrate from yarn to npm (5bfcd35)
    • 🤖 remove unnecessary webpack dependencies (a94b52b)
    • 🤖 remove unnecessary webpack-node-externals (979978e)
    • 🤖 update biome config to v2 (3b7f05f)
    • deps: update actions/labeler action to v7 (d962c63)
    • deps: update actions/stale action to v11 (0d9f8c8)
    • deps: update dependency sponsorkit to v19 (3ca6ff6)
    • deps: update endbug/add-and-commit action to v11 (d86e84f)
  2. v0.26.32026-03-25 · 2026-03-25 10:33 UTC
    查看更新说明

    0.26.3 (2026-03-25)

    Fixes

    • package.json & yarn.lock to reduce vulnerabilities (b01055d)

    Miscellaneous

    • 🤖 bump blade-formatter to 1.44.4 (8f259ba)
    • deps: bump flatted from 3.3.3 to 3.4.2 (32c689c)
    • deps: bump lodash from 4.17.21 to 4.17.23 (3a4f4ad)
    • deps: bump undici from 7.13.0 to 7.24.1 (2b2970f)
    • deps: update actions/cache action to v5 (6ac37f5)
    • deps: update actions/checkout action to v6 (a7a3541)
    • deps: update actions/labeler action to v6 (784a8d0)
    • deps: update actions/setup-node action to v6 (efc6750)
    • deps: update actions/stale action to v10 (6766b85)
    • deps: update all minor update of dev dependencies (fc7894f)
    • deps: update dependency ajv to v8.18.0 [security] (fb91c14)
    • deps: update dependency webpack to v5.104.1 [security] (1196bbd)
    • deps: update github/codeql-action action to v4 (626e5e7)
  3. v0.26.22025-08-11 · 2025-08-11 09:55 UTC
    查看更新说明

    0.26.2 (2025-08-11)

    Miscellaneous

    • 🤖 bump blade-formatter to 1.44.0 (b2d39af)
    • 🤖 bump blade-formatter to 1.44.1 (419296f)
    • 🤖 bump blade-formatter to 1.44.2 (bfbb78f)
    • 🤖 refresh dependencies (742887c)
    • 🤖 remove glob from dev dependency (84d51da)
    • deps: update akhilmhdh/contributors-readme-action action to v2.3.11 (d690317)
  4. v0.26.12025-07-18 · 2025-07-18 21:05 UTC
    查看更新说明

    0.26.1 (2025-07-18)

    Fixes

  5. v0.26.02025-07-18 · 2025-07-18 20:59 UTC
    查看更新说明

    0.26.0 (2025-07-18)

    Features

    • 🎸 add option no trailing comma php (5c95dc1)
    • 🎸 add option php version (0fd86a4)

    Miscellaneous

    • 🤖 bump @vscode/test-electron to 2.5.2 (20469fc)
    • 🤖 bump @vscode/vsce to 3.6.0 (d914d5f)
    • 🤖 bump blade-formatter to 1.43.0 (45d4cec)
    • deps: bump @babel/runtime-corejs3 from 7.16.7 to 7.28.0 (667b155)

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    CI Visual Studio Marketplace Version Visual Studio Marketplace Installs Visual Studio Marketplace Downloads Visual Studio Marketplace Rating

    vscode-blade-formatter

    An opinionated Blade file formatter for VSCode. Marketplace page is here.

    You can also format programmatically with the same syntax using the blade-formatter that this extension relies on.

    Features

    • Automatically indent markup inside directives
    • Automatically add spacing to blade template markers
    • PHP 8 support (null safe operator, named arguments) 🐘
    • PSR-2 support (format inside directives)
    • Automatically sort Tailwind CSS classes with respect of tailwind.config.js

    Screencast

    Screencast

    Extension Settings

    settingdescriptiondefault
    Blade Formatter: format EnabledWhether it enables or nottrue
    Blade Formatter: format Indent SizeAn indent size4
    Blade Formatter: format Wrap Line LengthThe length of line wrap size120
    Blade Formatter: format Wrap AttributesThe way to wrap attributes. [auto|force|force-aligned|force-expand-multiline|aligned-multiple|preserve|preserve-aligned]auto
    Blade Formatter: format Wrap Attributes Min AttrsMinimum number of html tag attributes for force wrap attribute options. Wrap the first attribute only if force-expand-multiline is specified in wrap attributes2
    Blade Formatter: format Sort Tailwind Css ClassesSort Tailwind CSS classes automaticallyfalse
    Blade Formatter: format Sort HTML AttributesSort HTML Attributes in the specified order. [none | alphabetical | code-guide | idiomatic | vuejs]none
    Blade Formatter: format Indent Inner HtmlIndent <head> and <body> sections in html.false
    Blade Formatter: format use TabsUse tab as indentation characterfalse
    Blade Formatter: format Custom Html Attributes OrderComma separated custom HTML attributes order. e.g. id, data-.+, class, name. To enable this you must specify sort html attributes option as custom. You can use regex for attribute names.none
    Blade Formatter: format No Multiple Empty LinesCollapses multiple blank lines into a single blank line.false
    Blade Formatter: format No PHP Syntax CheckDisable PHP Syntax check. Enabling this will suppress syntax error reporing.""
    Blade Formatter: format No Single QuoteUse double quotes instead of single quotes for php expression.false
    Blade Formatter: format No Trailing Comma PhpIf set to true, no trailing commas are printed for php expression.false
    Blade Formatter: format Component PrefixSpecify custom prefixes for component names separated by comma. e.g. x-,livewire. This changes the format rules applied to custom components e.g. preserve style in attributes.x-,livewire
    Blade Formatter: format PHP VersionA php version using for syntax compatibility.8.4
    Blade Formatter: Dont Show New Version MessageIf set to 'true', the new version message won't be shown anymore.false

    Configuration file: .bladeformatterrc.json or .bladeformatterrc

    To configure settings per project, put .bladeformatterrc.json or .bladeformatterrc to your project root will vscode-blade-formatter treat it as setting files.

    Configuration file will like below:

    {
        "indentSize": 4,
        "wrapAttributes": "auto",
        "wrapAttributesMinAttrs": 2,
        "wrapLineLength": 120,
        "endWithNewLine": true,
        "noMultipleEmptyLines": false,
        "useTabs": false,
        "sortTailwindcssClasses": true,
        "sortHtmlAttributes": "none",
        "noPhpSyntaxCheck": false,
        "noSingleQuote": false,
        "noTrailingCommaPhp": false,
        "componentPrefix": ["x-", "livewire:"],
        "phpVersion": "8.4"
    }
    

    Ignoring Files: .bladeignore

    To exclude files from formatting, create a .bladeignore file in the root of your project. .bladeignore uses gitignore syntax

    # Ignore email templates
    resources/views/email/**
    

    Disabling format in file

    To disable formatting in your file, you can use blade comments in the following format:

    {{-- blade-formatter-disable --}}
        {{ $foo }}
        {{ $bar }}
    {{-- blade-formatter-enable --}}
    

    To disable formatting on a specific line, you can use comment in the following format:

    {{-- blade-formatter-disable-next-line --}}
        {{ $foo }}
    

    To disable formatting for an entire file, put a {{-- blade-formatter-disable --}} comment at the beginning of the file:

    {{-- blade-formatter-disable --}}
    
    {{ $foo }}
    

    TODO

    • Add more option for HTML formatting rules
    • Add option for PHP formatting rules
    • Automate package publishing flow
    • Integration test

    Release Notes

    see CHANGELOG.md

    Related Projects

    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

    Development

    $ npm install
    $ cp .env.example .env # set your app insight key
    $ npm run watch # watch changes
    

    Testing

    $ npm install
    $ cp .env.example .env # set your app insight key
    $ npm run compile
    $ npm run test
    $ npm run test:e2e
    

    Sponsors

    Contributors

    LICENSE

    MIT

    Data and telemetry

    This extension collects usage data and sends it to Azure Application Insight to improve extension. This extension respects the telemetry.enableTelemetry setting.

    To opt out, please set the telemetry.enableTelemetry setting to false. Learn more in FAQ.