akalongman / sublimetext-codeformatter

Code Formatter plugin for ST2/ST3
MIT License
772 stars 130 forks source link

Issue on blade template #391

Open finalblast opened 5 years ago

finalblast commented 5 years ago

Hi,

Thanks @RevanProdigalKnight for the great formater version.

I am using Laravel (.blade.php) files and I am getting an issue as the following:

@foreach ($pages as $key => $page)
@if ($page->status_id == 2)
<tr>
    <td class="test">
        <a href="{{ route('pages.show', $page->id) }}">
            <h4 class="test">{{ $page->title }}</h4>
        </a>
    </td>
    <td></td>
    <td>
        <a href="{{ route('pages.show',$page->id) }}" class="test">
            <i class="test"></i>
        </a>
    </td>
</tr>
@endif
@endforeach

becomes

@foreach ($pages as $key =>
$page)
@if ($page->
status_id == 2)
<tr>
    <td class="test">
        <a href="{{ route('pages.show', $page->id) }}">
            <h4 class="test">{{ $page->title }}</h4>
        </a>
    </td>
    <td></td>
    <td>
        <a href="{{ route('pages.show',$page->id) }}" class="test">
            <i class="test"></i>
        </a>
    </td>
</tr>
@endif
@endforeach

My config:

"codeformatter_html_options":
{
    "syntaxes": "html,blade,twig,asp,xml", // Syntax names which must process HTML formatter
    "format_on_save": false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : "^((?!.min.|vendor).)*$"
    "formatter_version": "regexp", // Which formatter to use. Current options are "bs4" and "regexp". If an error occurs while loading the bs4 formatter, the regexp formatter will automatically be used
    "indent_size": 4, // indentation size
    "indent_char": " ", // Indentation character
    "indent_with_tabs": false, // Indent with one tab (overrides indent_size and indent_char options)
    "exception_on_tag_mismatch": true, // If the last closing tag is not at the same indentation level as the first opening tag, there's probably a tag mismatch in the file
    "expand_javascript": false, // (Under construction) Expand JavaScript inside of <script> tags (also affects CSS purely by coincidence)
    "expand_tags": false, // Expand tag attributes onto new lines
    "minimum_attribute_count": 2, // Minimum number of attributes needed before tag attributes are expanded to new lines
    "first_attribute_on_new_line": false, // Put all attributes on separate lines from the tag (only uses 1 indentation unit as opposed to lining all attributes up with the first)
    "reduce_empty_tags": true, // Put closing tags on same line as opening tag if there is no content between them
    "reduce_whole_word_tags": true, // Put closing tags on same line as opening tag if there is whole word between them
    "custom_singletons": "" // Custom singleton tags for various template languages outside of the HTML5 spec
},
atlazfin commented 4 years ago

Same issue for me <input id="customer_id" type="hidden" @if($c->customer) value="{{$c->customer->id}}" @else value="0" @endif />

turns into

 <input @if($c-="" id="customer_id" type="hidden">
    customer) value="{{$c->customer->id}}" @else value="0" @endif />
</input>