@lang('users.index')
-
@foreach($users as $user)
-
{{ link_to_route("frontend.users.user.show",$users["name"],$users['_id'])
@endforeach
### Install dependencies for development
Source: https://github.com/shufo/blade-formatter/blob/main/README.md
These commands install project dependencies and start a watch process for development. The watch command automatically rebuilds the project when files change, facilitating active development.
```bash
$ yarn install
$ yarn run watch # watch changes
```
--------------------------------
### Format Blade templates via CLI commands (Bash)
Source: https://context7.com/shufo/blade-formatter/llms.txt
Provides example command‑line usage of blade-formatter. Includes commands to format files and print the result to stdout, check whether files are already formatted, and apply formatting changes directly to files with optional progress indication.
```bash
# Format a single file
blade-formatter resources/views/layouts/app.blade.php
# Format multiple files with glob patterns
blade-formatter "resources/views/**/*.blade.php"
# Output shows formatted content on stdout
```
```bash
# Check if files need formatting
blade-formatter "resources/**/*.blade.php" --check-formatted
# Example output:
# Check formatting...
# resources/views/users/index.blade.php
# resources/views/products/show.blade.php
#
# Above file(s) are formattable. Forgot to run formatter? Use --write option to overwrite.
# Check exit code
echo $?
# 1 (non-zero if files need formatting)
```
```bash
# Format and write to files
blade-formatter "resources/**/*.blade.php" --write
# With progress indicator
blade-formatter "resources/**/*.blade.php" --write --progress
# Output: .F..E.F.
# Fixed: F
# Errors: E
# Not Changed: .
```
--------------------------------
### Install blade-formatter globally
Source: https://github.com/shufo/blade-formatter/blob/main/README.md
Installs the blade-formatter package globally on your system, making the command available from any directory. This is useful for running the formatter on multiple projects or for quick command-line usage.
```bash
$ npm install -g blade-formatter
$ yarn global add blade-formatter
```
--------------------------------
### Example Blade Input
Source: https://github.com/shufo/blade-formatter/blob/main/README.md
This is an example of an unformatted Blade template file, showcasing various Blade directives, HTML structure, and embedded PHP code.
```blade
@extends('frontend.layouts.app')
@section('title') foo
@endsection
@section('content')
@lang('users.index')
@foreach($users as $user)
{{ link_to_route("frontend.users.user.show",$users["name"],$users['_id'])
@lang('users.index')
@lang('users.index')
//Hello World
Hello World
//@lang('users.index')
{{ $user->name }}
@endif' | blade-formatter --stdin ``` ```bash docker run -it -v $(pwd):/app -w /app shufo/blade-formatter resources/**/*.blade.php ``` ```bash docker run -it -v $(pwd):/app -w /app shufo/blade-formatter resources/**/*.blade.php --write ``` ```bash docker run -it -v $(pwd):/app -w /app shufo/blade-formatter \ "resources/**/*.blade.php" \ --write \ --indent-size 2 \ --sort-tailwindcss-classes ``` -------------------------------- ### Define Blade Formatter settings in JSON configuration file Source: https://context7.com/shufo/blade-formatter/llms.txt Create a .bladeformatterrc.json file to specify project-wide formatting rules such as indentation, line length, Tailwind CSS integration, and attribute sorting. The configuration is read automatically by the formatter. ```json { "indentSize": 4, "wrapAttributes": "auto", "wrapLineLength": 120, "wrapAttributesMinAttrs": 2, "indentInnerHtml": true, "endWithNewLine": true, "endOfLine": "LF", "useTabs": false, "sortTailwindcssClasses": true, "tailwindcssConfigPath": "./tailwind.config.js", "sortHtmlAttributes": "none", "customHtmlAttributesOrder": ["id", "class", "name", "type", "value"], "noMultipleEmptyLines": false, "noPhpSyntaxCheck": false, "noSingleQuote": false, "noTrailingCommaPhp": false, "extraLiners": ["head", "body", "/html"], "componentPrefix": ["x-", "livewire:"], "phpVersion": "8.4" } ``` -------------------------------- ### Custom HTML attribute sorting via CLI and JSON configuration Source: https://context7.com/shufo/blade-formatter/llms.txt Configure custom sorting order for HTML attributes either through CLI flags or JSON settings. Supports regex patterns for flexible attribute matching. ```bash blade-formatter resources/views/*.blade.php \ --sort-html-attributes custom \ --custom-html-attributes-order "id,class,data-.*,name,type,value,href,src" \ --write ``` ```json { "sortHtmlAttributes": "custom", "customHtmlAttributesOrder": [ "id", "class", "^data-", "^aria-", "name", "type", "value", "placeholder", "href", "src", "alt", "^@click", "^@submit", "^x-" ] } ``` -------------------------------- ### Blade Ignore File Example (.bladeignore) Source: https://github.com/shufo/blade-formatter/blob/main/README.md Shows the format of a `.bladeignore` file used to specify files and directories that should be ignored by the blade formatter. It uses glob patterns similar to `.gitignore` to exclude specific files or all files within directories from formatting. ```gitignore resources/views/users/index.blade.php resources/views/products/* resources/views/books/**/* ``` -------------------------------- ### Set npm global user to root Source: https://github.com/shufo/blade-formatter/blob/main/README.md This command resolves permission issues encountered during global installation of blade-formatter. It configures npm to use root user for global operations, which can fix 'nobody does not have permission' errors. ```bash $ npm -g config set user root ``` -------------------------------- ### Format Blade templates using ESModule Source: https://github.com/shufo/blade-formatter/blob/main/README.md This snippet shows how to use the BladeFormatter API in an ESModule environment. It formats HTML/Blade content with configurable indent size. Requires ESModule support and the blade-formatter package to be installed. ```javascript import { Formatter } from "blade-formatter"; const input = `foo
`; const options = { indentSize: 2, }; new Formatter(options).formatContent(input).then((formatted) => { console.log(formatted); }); ``` -------------------------------- ### Disable Blade Formatter inline using Blade comments Source: https://context7.com/shufo/blade-formatter/llms.txt Use Blade comment directives to temporarily disable formatting for sections or lines within a template. Helpful for preserving custom formatting or code snippets. ```blade {{-- blade-formatter-disable --}}foo
`; const options = { indentSize: 4, wrapAttributes: "auto", wrapLineLength: 120, endWithNewLine: true, useTabs: false, sortTailwindcssClasses: true, }; new BladeFormatter(options).format(input).then((formatted) => { console.log(formatted); }); ``` -------------------------------- ### Run tests with Docker Source: https://github.com/shufo/blade-formatter/blob/main/README.md These commands build and test the project using Docker. The debug command allows attaching to the container for troubleshooting. Useful for ensuring consistent test results across different environments. ```bash $ make build $ make test $ make debug # attach ``` -------------------------------- ### Show diffs with blade-formatter Source: https://github.com/shufo/blade-formatter/blob/main/README.md Formats specified blade template files and displays the differences (diffs) between the original and formatted versions. This is useful for code reviews or understanding the impact of the formatter. ```bash $ blade-formatter -c -d resources/**/*.blade.php ``` -------------------------------- ### Format files using blade-formatter CLI Source: https://github.com/shufo/blade-formatter/blob/main/README.md Formats specified blade template files and outputs the formatted result to standard output. This command is useful for integrating into scripts or for reviewing formatted code before writing it to files. ```bash # This outputs formatted result to stdout $ blade-formatter resources/**/*.blade.php $ blade-formatter resources/layouts/app.blade.php ``` -------------------------------- ### Configure package for ESModule support Source: https://github.com/shufo/blade-formatter/blob/main/README.md This configuration enables ESModule support in Node.js projects. It's required when using ESModule syntax in files like tailwind.config.js. The setting should be added to package.json. ```json "type": "module" ``` -------------------------------- ### Tailwind CSS configuration for CommonJS Source: https://github.com/shufo/blade-formatter/blob/main/README.md This is the required Tailwind CSS configuration format when using CommonJS. It uses module.exports syntax which is compatible with CommonJS environments. Should be saved as tailwind.config.js. ```javascript module.exports = { ~~~ } ``` -------------------------------- ### Format and overwrite files with blade-formatter Source: https://github.com/shufo/blade-formatter/blob/main/README.md Formats specified blade template files and overwrites them with the formatted content. Use this command when you are confident in the formatting and want to apply changes directly to your files. ```bash $ blade-formatter --write resources/**/*.blade.php ``` -------------------------------- ### Tailwind CSS configuration for ESM Source: https://github.com/shufo/blade-formatter/blob/main/README.md This is the required Tailwind CSS configuration format when using ESModule. It uses export default syntax which is compatible with ESModule environments. Should be saved as tailwind.config.js. ```javascript export default { ~~~ } ``` -------------------------------- ### Check formatting status with blade-formatter Source: https://github.com/shufo/blade-formatter/blob/main/README.md Checks if blade template files are formatted correctly without making any changes. It returns an exit code of 1 if any files are not formatted, indicating that the formatter needs to be run. ```bash $ 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 $? ``` -------------------------------- ### Disable Blade Formatting with Blade Comments Source: https://github.com/shufo/blade-formatter/blob/main/README.md Illustrates how to disable code formatting within Blade files using special Blade comments. `blade-formatter-disable` and `blade-formatter-enable` comments can bracket sections of code to be excluded from formatting. `blade-formatter-disable-next-line` can be used to skip formatting for a single subsequent line. ```blade {{-- blade-formatter-disable --}} {{ $foo }} {{ $bar }} {{-- blade-formatter-enable --}} ``` ```blade {{-- blade-formatter-disable-next-line --}} {{ $foo }} ``` ```blade {{-- blade-formatter-disable --}} {{ $foo }} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.