Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1034,10 +1034,13 @@ function printLines(path, options, print, childrenAttribute = "children") {
}

if (isInlineNode) {
const openTag =
nextNode && nextNode.kind === "echo" && nextNode.shortForm
? "<?="
: "<?php";
const shortOpenTag =
nextNode && nextNode.kind === "echo" && nextNode.shortForm;
if (shortOpenTag) {
parts.push(concat(["<?=", " ", printed, " ", "?>"]));
return;
}
const openTag = shortOpenTag ? "<?=" : "<?php";
const beforeInline =
childNode.leadingComments && childNode.leadingComments.length
? concat([
Expand Down
15 changes: 15 additions & 0 deletions tests/inline/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2532,3 +2532,18 @@ printWidth: 80

================================================================================
`;

exports[`shorthand-2.php 1`] = `
====================================options=====================================
parsers: ["php"]
printWidth: 80
| printWidth
=====================================input======================================
<?= $var1 ?><?= $var2 ?>

=====================================output=====================================
<?= $var1 ?><?=
$var2 ?>

================================================================================
`;
1 change: 1 addition & 0 deletions tests/inline/shorthand-2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?= $var1 ?><?= $var2 ?>