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

Fix #86, deIndent template code before preprocessing #90

Merged
merged 5 commits into from
May 12, 2017
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 5 additions & 5 deletions src/vueTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ async function processTemplate (source, id, content, options, nodes, modules) {
debug(`Process template: ${id}`)

const extras = { modules, id, lang: source.attrs.lang }
const { code } = source
const template = deIndent(
await (options.disableCssModuleStaticReplacement !== true
? templateProcessor(code, extras, options)
: code)
const code = deIndent(source.code)
const template = await (
options.disableCssModuleStaticReplacement !== true
? templateProcessor(code, extras, options)
: code
)

if (!options.compileTemplate) {
Expand Down
2 changes: 1 addition & 1 deletion 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\"><article><p>foo</p></article></div>",cssModules: {"test":"pug__test"},};
var pug = { template: "<div class=\"pug__test keep-me\" v-if=\"true\"><article><p>foo</p></article></div><p v-else=\"v-else\">nothing</p>",cssModules: {"test":"pug__test"},};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does v-else correctly work here? It seems pug cannot know v-else is a boolean attribute but Vue compiler does not care. I'm not a pug user personally. Maybe @aleksejevski can give a comment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need specify doctype option for pug compiler.
https://pugjs.org/language/doctype.html#doctype-option

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I don't know that!


export default pug;
6 changes: 4 additions & 2 deletions test/fixtures/pug.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<template lang="pug">


div(class=css.test class='keep-me')
div(class=css.test class='keep-me' v-if="true")
article
p foo
p(v-else)
| nothing



</template>

<script lang="babel">
Expand Down