Ugly HTML with inline PHP
Not sure if the following snippet should be as badly malformatted as it is? I'd expect the output to be similar to the input — but it gets pretty mangled.
If this is expected right now (because of the beta state) then feel free to close the issue.
Prettier 1.16.4
PHP Plugin 0.10.2
Options:
{
"tabWidth": 4,
"useTabs": true,
Input:
<div class="branchfinder-branches">
<?php
$branches = $block->getBranches();
foreach ($branches as $branch):
?>
<article><?= $branch ?></article>
<?php endforeach; ?>
</div>
Output:
<div class="branchfinder-branches">
<?php
$branches = $block->getBranches();
foreach ($branches as $branch): ?>
<article><?= $branch ?></article>
<?php endforeach;
?>
</div>
Expected behavior:
Output same as input.
@mdtrooper HTML with inline PHP was ugly in Prettier last time I checked. I'd love it to be improved (it's not the fault of the file extension though, it's a wider issue).
To make my code sample correctly formatted, the rules needed would be:
- Look at how many tabs exist on the line where the opening
<?phptag is, and prepend that many tabs (plus one) to the PHP code in that block. - Put the closing
?>tag on the same line if the code contains only a single statement (and is shorter than the line length etc), but don't otherwise.
I'm not familiar with the Prettier code base or plugin framework, so it's probably very difficult to implement the formatting rules I've specified there.