Skip to content

Commit

Permalink
fix: 🐛 indentation removed when raw blade brace is multi-lined
Browse files Browse the repository at this point in the history
  • Loading branch information
shufo committed Jul 6, 2022
1 parent 3d1b494 commit 42e7c0f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1437,18 +1437,22 @@ export default class Formatter {
res,
new RegExp(`${this.getRawBladeBracePlaceholder('(\\d+)')}`, 'gms'),
(_match: any, p1: any) => {
const placeholder = this.getRawBladeBracePlaceholder(p1);
const matchedLine = content.match(new RegExp(`^(.*?)${placeholder}`, 'gmi')) ?? [''];
const indent = detectIndent(matchedLine[0]);
const bladeBrace = this.rawBladeBraces[p1];

if (bladeBrace.trim() === '') {
return `{!!${bladeBrace}!!}`;
}

return `{!! ${util
.formatRawStringAsPhp(bladeBrace)
.replace(/([\n\s]*)->([\n\s]*)/gs, '->')
.trim()
// @ts-expect-error ts-migrate(2554) FIXME: Expected 0 arguments, but got 1.
.trimRight('\n')} !!}`;
return this.indentRawPhpBlock(
indent,
`{!! ${util
.formatRawStringAsPhp(bladeBrace, this.wrapLineLength)
.replace(/([\n\s]*)->([\n\s]*)/gs, '->')
.trim()} !!}`,
);
},
),
);
Expand Down

0 comments on commit 42e7c0f

Please sign in to comment.