RiFi2k / format-html-in-php

Basically this vscode extension uses all your standard configurations for html formatting, and your standard configurations for format on save, etc. It more or less works exactly how vscode should already work as it pertains to HTML in PHP files.
The Unlicense
33 stars 6 forks source link

Respecting php identation #45

Open IvanBrkicNeuralab opened 4 years ago

IvanBrkicNeuralab commented 4 years ago
<?php
if ($var1){
    if (!$var2){
        ?>
        <div class="cla"></div>
        <?php
    }
}

Formatting the above code produces the following result.

if ($var1){
    if (!$var2){
        ?>
<div class="cla"></div>
<?php
    }
}

Is this intended like so?

RiFi2k commented 4 years ago

@ivanbrkicNRLB I'll see what I can do about this, I agree it's annoying.

RiFi2k commented 4 years ago

Dup of #44

ghost commented 3 years ago

I came here looking for a fix to something similar. Please can you include the cases of if and foreach which at the moment doesn't respect indents. Thanks screen-2020-11-20_10-20-30

...examples of the sort of indentation that breaks included as screenshot because my comment code inserts are breaking the github editor right now!

// edit -- is this out of scope since its a php indent rather than html? It would be nice if the formatter could just ignore these indents rather than 'correct' them to be at the same level as the surrounding tags

abuhenaa commented 3 years ago

I'm facing the same issue.. Is there any solution ? Please ... @RiFi2k

james0r commented 1 year ago

I also use a lot of alternate syntax and it would be great if nested control structures were indented. VS Code intelliphense does this pretty nicely but can't handle attributes on their own line so at the moment I get either/or.

Wanting:

<?php if ($something == false) : ?>
  <?php if (false == true) : ?>
    <?php echo 'print something' ?>
  <?php endif; ?>
<?php endif; ?>

Currently getting:

<?php if ($something == false) : ?>
<?php if (false == true) : ?>
<?php echo 'print something' ?>
<?php endif; ?>
<?php endif; ?>