format-html-in-php icon indicating copy to clipboard operation
format-html-in-php copied to clipboard

Respecting php identation

Open IvanBrkicNeuralab opened this issue 5 years ago • 5 comments

<?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?

IvanBrkicNeuralab avatar Jul 21 '20 10:07 IvanBrkicNeuralab

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

RiFi2k avatar Aug 28 '20 07:08 RiFi2k

Dup of #44

RiFi2k avatar Aug 28 '20 07:08 RiFi2k

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

ghost avatar Nov 20 '20 09:11 ghost

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

abuhenaa avatar May 05 '21 19:05 abuhenaa

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; ?>

james0r avatar Jun 21 '23 02:06 james0r