Skip to content

Commit

Permalink
group params and block params separately in block statements
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescdavis committed Dec 27, 2022
1 parent 948b3af commit e4d310a
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/language-handlebars/printer-glimmer.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,19 +535,22 @@ function printOpenBlock(path, print) {

const attributes = [printPath(path, print)];

const params = printParams(path, print);
if (params) {
attributes.push(line, params);
const pparams = printParams(path, print);
let params = [];
if (pparams) {
params = [line, group(pparams)];
}

let blockParams = [];
if (isNonEmptyArray(node.program.blockParams)) {
const block = printBlockParams(node.program);
attributes.push(line, block);
blockParams = [line, printBlockParams(node.program)];
}

return group([
openingMustache,
indent(attributes),
indent(params),
indent(blockParams),
softline,
closingMustache,
]);
Expand All @@ -564,8 +567,12 @@ function printElseBlock(node, options) {

function printElseIfLikeBlock(path, print, ifLikeKeyword) {
const node = path.getValue();
let blockParams = [];

const attributes = group(["else", line, ifLikeKeyword]);

const params = [line, group(printParams(path, print))];

let blockParams = [];
if (isNonEmptyArray(node.program.blockParams)) {
blockParams = [line, printBlockParams(node.program)];
}
Expand All @@ -574,13 +581,8 @@ function printElseIfLikeBlock(path, print, ifLikeKeyword) {

return group([
printInverseBlockOpeningMustache(parentNode),
indent(
group([
group(["else", line, ifLikeKeyword]),
line,
printParams(path, print),
])
),
indent(attributes),
indent(params),
indent(blockParams),
softline,
printInverseBlockClosingMustache(parentNode),
Expand Down

0 comments on commit e4d310a

Please sign in to comment.