Skip to content
This repository was archived by the owner on Dec 26, 2018. It is now read-only.

Commit 20bd7f4

Browse files
crookedneighboryyx990803
authored andcommitted
Add pug support (#80)
Closes #79
1 parent dfd0ba1 commit 20bd7f4

File tree

6 files changed

+37
-7
lines changed

6 files changed

+37
-7
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ These are the built-in preprocessors:
148148
- less
149149
- scss (via `node-sass`)
150150
- jade
151+
- pug
151152
- coffee-script
152153

153154
## Autoprefix by Default

lib/compilers/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ module.exports = {
66
sass: require('./sass'),
77
scss: require('./sass'),
88
stylus: require('./stylus'),
9-
jade: require('./jade')
9+
jade: require('./jade'),
10+
pug: require('./pug')
1011
}

lib/compilers/pug.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var options = require('./options')
2+
3+
module.exports = function (raw, cb) {
4+
try {
5+
var pug = require('pug')
6+
} catch (err) {
7+
return cb(err)
8+
}
9+
try {
10+
var html = pug.compile(raw, options.pug || {})()
11+
} catch (err) {
12+
return cb(err)
13+
}
14+
cb(null, html)
15+
}

package.json

+7-6
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,18 @@
4545
"vue-hot-reload-api": "^1.2.0"
4646
},
4747
"devDependencies": {
48+
"babel-core": "^6.1.2",
49+
"babel-plugin-transform-runtime": "^6.1.2",
50+
"babel-preset-es2015": "^6.1.2",
51+
"babel-runtime": "^5.8.0",
4852
"coffee-script": "^1.10.0",
4953
"jade": "^1.11.0",
5054
"less": "^2.5.1",
5155
"mocha": "^2.3.3",
5256
"node-sass": "^3.3.3",
57+
"pug": "^2.0.0-alpha6",
5358
"stylus": "^0.52.4",
54-
"vueify-insert-css": "^1.0.0",
55-
"babel-core": "^6.1.2",
56-
"babel-runtime": "^5.8.0",
57-
"babel-preset-es2015": "^6.1.2",
58-
"babel-plugin-transform-runtime": "^6.1.2",
59-
"vue-hot-reload-api": "^1.2.0"
59+
"vue-hot-reload-api": "^1.2.0",
60+
"vueify-insert-css": "^1.0.0"
6061
}
6162
}

test/expects/pug.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
;(typeof module.exports === "function"? module.exports.options: module.exports).template = "<ul><li>foo<li>bar<li>baz</ul><ul><li>foo<li>bar<li>baz</ul>"

test/fixtures/pug.vue

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<template lang="pug">
2+
//- Declaration
3+
mixin list
4+
ul
5+
li foo
6+
li bar
7+
li baz
8+
//- Use
9+
+list
10+
+list
11+
</template>

0 commit comments

Comments
 (0)