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

Trim templates before pug compiling (#86) #89

Merged
merged 4 commits into from
May 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/template/pug.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export default async function (template, extras, options) {
const pug = require('pug')
const compiler = pug.compile(template, { filename: extras.id, ...options.pug })
const trim = typeof template === 'string' ? template.trim() : template
const compiler = pug.compile(trim, { filename: extras.id, ...options.pug })

return compiler({css: extras.modules || {}})
}
4 changes: 2 additions & 2 deletions test/expects/pug.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
var pug = { template: "<div class=\"pug__test keep-me\">foo</div>",cssModules: {"test":"pug__test"},};
var pug = { template: "<div class=\"pug__test keep-me\"><article><p>foo</p></article></div>",cssModules: {"test":"pug__test"},};

export default pug;
export default pug;
8 changes: 7 additions & 1 deletion test/fixtures/pug.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<template lang="pug">
div(class=css.test class='keep-me') foo


div(class=css.test class='keep-me')
article
p foo


</template>

<script lang="babel">
Expand Down