prettier / prettier/plugin-php
Breaks if comments precede an include statement in mixed HTML/PHP files
Nessuno ha ancora preso questa issue.
- Lingua principale
- PHP
- Stelle
- 1.9k
- Fork
- 139
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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(); ?>
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riproduci l’input nel playground Prettier PHP collegato e confrontalo con l’output segnalato, concentrandoti sui commenti prima delle istruzioni include nei template HTML/PHP misti. Traccia il punto di ingresso del formatter per questo caso del playground; il lavoro è completato quando il commento non viene duplicato, il delimitatore PHP di chiusura non viene inserito prematuramente e include rimane formattato correttamente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- php, wordpress
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 45/100