Skip to content
Merged
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
3 changes: 2 additions & 1 deletion src/printer/print/liquid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,11 @@ export function printLiquidBlockStart(
}

if (lines.length > 1) {
const reindentedLines = reindent(lines, true);
return group([
'{%',
whitespaceStart,
indent([hardline, node.name, ' ', join(hardline, lines.map(trim))]),
indent([hardline, node.name, ' ', join(hardline, reindentedLines)]),
hardline,
whitespaceEnd,
'%}',
Expand Down
14 changes: 14 additions & 0 deletions test/twig-set-object-indentation/fixed.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
It should preserve nested object indentation in multi-line set tags
{%
set defaultAttributes = {
id: null,
alt: null,
class: 'w-full h-full rounded-lg aspect-square object-cover border bg-neutral image-preview',
stimulus: {
controllers: {
target: 'target-name'
}
}
}
%}

14 changes: 14 additions & 0 deletions test/twig-set-object-indentation/index.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
It should preserve nested object indentation in multi-line set tags
{%
set defaultAttributes = {
id: null,
alt: null,
class: 'w-full h-full rounded-lg aspect-square object-cover border bg-neutral image-preview',
stimulus: {
controllers: {
target: 'target-name'
}
}
}
%}

6 changes: 6 additions & 0 deletions test/twig-set-object-indentation/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { assertFormattedEqualsFixed } from '../test-helpers';
import * as path from 'path';

describe(`Unit: ${path.basename(__dirname)}`, () => {
assertFormattedEqualsFixed(__dirname);
});