调整 Laravel Blade 的 Atom-Beautify/JS-Beautify

Sla*_*lam 6 php js-beautify atom-editor laravel-blade atom-beautify

我喜欢在 Atom 中自定义 JS-Beautify 以更好地格式化我的刀片文件。

我们的手动样式如下所示:

{{--
  Template Name: Full Width Template
--}}
<!-- template-fullwidth -->

@extends('layouts.app')

@section('content')
  @while(have_posts()) 
    @php the_post() @endphp
    @include('sections.content-page')
  @endwhile
@endsection
Run Code Online (Sandbox Code Playgroud)

JS-Beautify 给了我们这个:

{{-- Template Name: Full Width Template
--}}
<!-- template-fullwidth -->
@extends('layouts.app')
@section('content')
@while(have_posts())
@php the_post()
@endphp
@include('sections.content-page')
@endwhile
@endsection
Run Code Online (Sandbox Code Playgroud)

我试过配置 .jsbeautifyrc 文件,但没有成功。

我想:

  1. 保留注释行
  2. 在选择指令前添加一个空行 [@extends, @section]
  3. @section 指令中的缩进行
  4. 缩进@while 和@if 中的项目
  5. 将@php 代码和@endphp 放在一行

或者,如果所有这些都失败了,则需要某种可读的、格式良好的代码,而不仅仅是一长串指令。

这能做到吗?