goognet / blade-pint
Makes Laravel Pint print plain HTML void elements in Blade views, without changing how you run Pint.
Requires
- php: ^8.3.0
- composer-plugin-api: ^2.3
- laravel/pint: ^1.32.1
Requires (Dev)
- composer/composer: ^2.8.0
- pestphp/pest: ^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Makes Laravel Pint print plain HTML void elements in Blade views. You keep running Pint exactly as you do today.
Pint formats Blade through Prettier, whose HTML printer terminates every void element the XHTML way:
<br> <br /> <meta charset="utf-8"> → <meta charset="utf-8" /> <input type="text"> <input type="text" />
That is valid HTML5, but projects that want their emitted markup to stay plain HTML have no way to ask Pint for it.
Installation
composer require --dev goognet/blade-pint
That is the whole setup. There is no new binary, no new command, and nothing to add to pint.json:
vendor/bin/pint --blade vendor/bin/pint --blade --test
Your editor integration, git hooks and CI keep calling Pint and get the new output for free.
How it works
The Prettier plugin Pint formats Blade with, prettier-plugin-blade, already supports the option:
| option | values | default |
|---|---|---|
bladeVoidElementSlash |
"always", "never", "preserve" |
"always" |
Pint simply does not expose it. Pint ships its Prettier configuration as a plain file rather than inside its PHAR, at vendor/laravel/pint/resources/prettier/prettierrc.json, so this package is a Composer plugin that sets "bladeVoidElementSlash": "never" on it — after every composer install and composer update, so a Pint upgrade never quietly loses it.
Because the option is Prettier's own, Pint's output is the final output: pint --test stays accurate, the cache stays correct, and nothing runs after Pint.
Removing the package puts the configuration back:
composer remove --dev goognet/blade-pint
What changes
Only the fourteen HTML void elements — area, base, br, col, embed, hr, img, input, link, meta, param, source, track, wbr.
Blade, Livewire and Flux components, custom elements and SVG content keep their />, since the slash is meaningful there:
<x-icon name="star" /> <livewire:counter /> <svg viewBox="0 0 16 16"><path d="M0 0" /></svg>
After installing
Pint's cache is not keyed on this option, so views it has already formatted keep their terminator until they change. Reformat them once with a fresh cache:
vendor/bin/pint --blade --cache-file "$(mktemp)"
Requirements
- PHP 8.3+
laravel/pint^1.32.1prettier-plugin-blade3.3.0+, which Pint installs itself on first run
The plugin warns instead of failing when it cannot find the Pint configuration, so a Pint release that moves or bundles the file leaves your builds working — without the option.
License
MIT. See LICENSE.md.