Skip to content

Commit 8db5436

Browse files
authored
Fix generated duplicate period with pugClassLocation (#316)
1 parent 490f816 commit 8db5436

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

src/printer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ export class PugPrinter {
10881088
: '';
10891089
let result: string = `${this.computedIndent}${optionalDiv}`;
10901090
if (this.options.pugClassLocation === 'after-attributes') {
1091-
this.classLiteralAfterAttributes.push(val);
1091+
this.classLiteralAfterAttributes.push(val.slice(1));
10921092
} else {
10931093
result += val;
10941094
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
v-row(no-gutters)
2+
v-col(cols="12")
3+
div(v-t="'global.copy-variables-title'").text-body-2.font-weight-medium
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { readFileSync } from 'fs';
2+
import { resolve } from 'path';
3+
import { format } from 'prettier';
4+
import { plugin } from './../../../src/index';
5+
6+
describe('Issues', () => {
7+
test('should not add double "." when formatting class location', () => {
8+
const expected: string = readFileSync(resolve(__dirname, 'formatted.pug'), 'utf8');
9+
const code: string = readFileSync(resolve(__dirname, 'unformatted.pug'), 'utf8');
10+
const actual: string = format(code, {
11+
parser: 'pug',
12+
plugins: [plugin],
13+
14+
pugClassLocation: 'after-attributes'
15+
});
16+
17+
expect(actual).toBe(expected);
18+
});
19+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
v-row(no-gutters)
2+
v-col(cols="12")
3+
.text-body-2.font-weight-medium(v-t="'global.copy-variables-title'")

0 commit comments

Comments
 (0)