Skip to content

Commit

Permalink
Fix indentation for doctype
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Quadflieg committed Feb 14, 2020
1 parent 2048001 commit 51d3860
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ test/pug-tests/attrs.unescaped.formatted.pug
test/pug-tests/attrs.unescaped.pug
test/pug-tests/block-code.formatted.pug
test/pug-tests/block-code.pug
test/pug-tests/blocks-in-if.formatted.pug
test/pug-tests/blocks-in-if.pug
test/pug-tests/comments.formatted.pug
test/pug-tests/comments.pug
test/pug-tests/comments.source.formatted.pug
Expand Down
2 changes: 1 addition & 1 deletion src/printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ export class PugPrinter {
}

private doctype(token: DoctypeToken): string {
let result = 'doctype';
let result = `${this.computedIndent}doctype`;
if (token.val) {
result += ` ${token.val}`;
}
Expand Down
19 changes: 19 additions & 0 deletions test/pug-tests/blocks-in-if.formatted.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//- see https://github.com/pugjs/pug/issues/1589
- var ajax = true;

- if( ajax )
//- return only contents if ajax requests
block contents
p ajax contents

- else
//- return all html
doctype html
html
head
meta(charset="utf8")
title sample
body
block contents
p all contetns
19 changes: 19 additions & 0 deletions test/pug-tests/blocks-in-if.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//- see https://github.com/pugjs/pug/issues/1589
-var ajax = true

-if( ajax )
//- return only contents if ajax requests
block contents
p ajax contents

-else
//- return all html
doctype html
html
head
meta( charset='utf8' )
title sample
body
block contents
p all contetns

0 comments on commit 51d3860

Please sign in to comment.