plugin-php
plugin-php copied to clipboard
Breaks if comments precede an include statement in mixed HTML/PHP files
When running the plugin on a Wordpress template file with some commented lines, behaviour is not as expected.
In this example, the comment line (line 22 in the playground) // $feed_section_class = 'has-top-padding grey-bg'; somehow is duplicated and the closing ?> is inserted prematurely.
@prettier/plugin-php v0.15.2 Playground link
Input:
<?php
/*
Template Name: File
*/
get_header(); ?>
<?php
$home_url = home_url();
$theme_path = get_template_directory_uri();
?>
<main>
<?php include locate_template('content-product-secondary-nav.php'); ?>
<section>
<h1>Title</h1>
<p>Some content here</p>
</section>
<?php // $feed_section_class = 'has-top-padding grey-bg';
// include( locate_template( 'content-brilliance-feeds.php' ) );
include locate_template('content-sub-footer.php'); ?>
</main>
<?php get_template_part('content', 'brochure-popup'); ?>
<?php get_template_part('content', 'quote-popup'); ?>
<?php get_footer(); ?>
Output:
<?php
/*
Template Name: File
*/
get_header(); ?>
<?php
$home_url = home_url();
$theme_path = get_template_directory_uri();
?>
<main>
<?php include locate_template('content-product-secondary-nav.php'); ?>
<section>
<h1>Title</h1>
<p>Some content here</p>
</section>
<?php // $feed_section_class = 'has-top-padding grey-bg';
// $feed_section_class = 'has-top-padding grey-bg';
?>// include( locate_template( 'content-brilliance-feeds.php' ) );
include locate_template('content-sub-footer.php'); ?>
</main>
<?php get_template_part('content', 'brochure-popup'); ?>
<?php get_template_part('content', 'quote-popup'); ?>
<?php get_footer(); ?>
Same here. This is crucial.
I wonder if this is a manifestation of this bug: https://github.com/prettier/plugin-php/issues/1736