Looking to hire Laravel developers? Try LaraJobs

laravel-blade-indenter maintained by bgaze

Description
A basic indenter for Laravel 5.8+ Blade templates
Author
Last update
2020/06/02 06:19 (dev-master)
License
Links
Downloads
63

Comments
comments powered by Disqus

Basic indenter for Laravel 5.8+ Blade templates

This is a very simple indenter for Laravel Blade template, mainly designed to indent generated files in my CRUD generator for Laravel.

It won't format or validate code: it just indent existing lines following very simple rules.
It expects a valid and well formed code, and won't deal well with instructions on multiple lines.

Any contribution or feedback is highly welcomed, please feel free to create a pull request or submit a new issue.

Documentation

Full documentation is available at https://packages.bgaze.fr/laravel-blade-indenter

Quick start

Simply import the package with composer:

composer require bgaze/laravel-blade-indenter

Configuration can be published to /config/blade-indenter.php:

php artisan vendor:publish --tag=blade-indenter-config

The package exposes a single service which indents Blade string :

use Bgaze\BladeIndenter\BladeIndenter;

$indentedString = resolve(BladeIndenter::class)->indent($stringToIndent);

Two helpers are also provided for convenience :

// Indent a string
$indentedString = indent_blade_string($stringToIndent);

// Indent a blade file, overwrite it and return formatted content.
$indentedFileContent = indent_blade_file($filePath);

// Indent a blade file and return formatted content without overwriting.
$indentedFileContent = indent_blade_file($filePath, false);