Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit 855006b

Browse files
aleksejevskiznck
authored andcommitted
Trim templates before pug compiling (#86) (#89)
* Trim templates before pug compiling (#86) * Fix a mistake (#86) * Add few nested tags * Update expected output for pug.vue
1 parent 713c5a6 commit 855006b

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/template/pug.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export default async function (template, extras, options) {
22
const pug = require('pug')
3-
const compiler = pug.compile(template, { filename: extras.id, ...options.pug })
3+
const trim = typeof template === 'string' ? template.trim() : template
4+
const compiler = pug.compile(trim, { filename: extras.id, ...options.pug })
45

56
return compiler({css: extras.modules || {}})
67
}

test/expects/pug.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
var pug = { template: "<div class=\"pug__test keep-me\">foo</div>",cssModules: {"test":"pug__test"},};
1+
var pug = { template: "<div class=\"pug__test keep-me\"><article><p>foo</p></article></div>",cssModules: {"test":"pug__test"},};
22

3-
export default pug;
3+
export default pug;

test/fixtures/pug.vue

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<template lang="pug">
2-
div(class=css.test class='keep-me') foo
2+
3+
4+
div(class=css.test class='keep-me')
5+
article
6+
p foo
7+
8+
39
</template>
410

511
<script lang="babel">

0 commit comments

Comments
 (0)