Skip to content

Commit 3969c3c

Browse files
committed
set default options for pug preprocessor
1 parent f3af513 commit 3969c3c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/compileTemplate.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function compileTemplate(
4242
if (preprocessor) {
4343
return actuallyCompile(
4444
Object.assign({}, options, {
45-
source: preprocess(options, preprocessor)
45+
source: preprocess(options, preprocessor, preprocessLang as string)
4646
})
4747
)
4848
} else if (preprocessLang) {
@@ -65,16 +65,24 @@ export function compileTemplate(
6565
}
6666
}
6767

68+
function getDefaultPreprocessOptions(preprocessLang: string): any {
69+
const defaultPreprocessOptions: any = { pug: { doctype: 'html' } }
70+
71+
return defaultPreprocessOptions[preprocessLang] || {}
72+
}
73+
6874
function preprocess(
6975
options: TemplateCompileOptions,
70-
preprocessor: any
76+
preprocessor: any,
77+
preprocessLang: string
7178
): string {
7279
const { source, filename, preprocessOptions } = options
7380

7481
const finalPreprocessOptions = Object.assign(
7582
{
7683
filename
7784
},
85+
getDefaultPreprocessOptions(preprocessLang),
7886
preprocessOptions
7987
)
8088

0 commit comments

Comments
 (0)