-
-
Notifications
You must be signed in to change notification settings - Fork 138
How to format HTML in PHP templates #845
Copy link
Copy link
Closed
Labels
Description
Prettier 1.15.2
PHP Plugin 0.9.0
Now that prettier supports formatting HTML, how can we have plugin-php format PHP and HTML in a PHP file?
Input:
<?php
$somePoorly = 'formatted'. 'code' .
'right' .
( isset( $nope) ? 'here'
:
'and here'
)
;
?>
<html
><head
>
</head>
<body>
More
bad
code here.
</body
>
</html>
Output of prettier test.php: (PHP is properly formatted, HTML is not.)
<?php
$somePoorly =
'formatted' . 'code' . 'right' . (isset($nope) ? 'here' : 'and here'); ?>
<html
><head
>
</head>
<body>
More
bad
code here.
</body
>
</html>Output of prettier test.php --parser html: (HTML is properly formatted, PHP is not.)
<?php $somePoorly = 'formatted'. 'code' . 'right' . ( isset( $nope) ? 'here' :
'and here' ) ; ?>
<html>
<head> </head>
<body>
More bad code here.
</body>
</html>Expected behavior: (Both PHP & HTML are properly formatted.)
<?php
$somePoorly =
'formatted' . 'code' . 'right' . (isset($nope) ? 'here' : 'and here'); ?>
<html>
<head> </head>
<body>
More bad code here.
</body>
</html>Reactions are currently unavailable