shufo / prettier-plugin-blade

Format your blade template using Prettier
https://www.npmjs.com/package/@shufo/prettier-plugin-blade
MIT License
317 stars 8 forks source link

[Feature Request]: Support nested PHP tags #281

Closed vinkla closed 1 month ago

vinkla commented 2 months ago

Description

This plugin is excellent for formatting PHP templates with and without Blade syntax. Nested PHP tags do not appear to be indented unless there is HTML between them.

<?php if (have_posts()): ?>

<?php while (have_posts()): ?>

<article>
    <header>
        <h1><?php the_title(); ?></h1>
    </header>
</article>

<?php endwhile; ?>

<?php endif; ?>

It works better if you place an HTML tag between the if and while statements.

<?php if (have_posts()): ?>

<div>
    <?php while (have_posts()): ?>

    <article>
        <header>
            <h1><?php the_title(); ?></h1>
        </header>
    </article>

    <?php endwhile; ?>
</div>

<?php endif; ?>

Suggested Solution

Add support for indentation in nested PHP tags, regardless of the syntax used.

Alternatives

No response

Additional Context

No response