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

Commit

Permalink
Add pug support (#80)
Browse files Browse the repository at this point in the history
Closes #79
  • Loading branch information
crookedneighbor authored and yyx990803 committed May 3, 2016
1 parent dfd0ba1 commit 20bd7f4
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ These are the built-in preprocessors:
- less
- scss (via `node-sass`)
- jade
- pug
- coffee-script

## Autoprefix by Default
Expand Down
3 changes: 2 additions & 1 deletion lib/compilers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ module.exports = {
sass: require('./sass'),
scss: require('./sass'),
stylus: require('./stylus'),
jade: require('./jade')
jade: require('./jade'),
pug: require('./pug')
}
15 changes: 15 additions & 0 deletions lib/compilers/pug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var options = require('./options')

module.exports = function (raw, cb) {
try {
var pug = require('pug')
} catch (err) {
return cb(err)
}
try {
var html = pug.compile(raw, options.pug || {})()
} catch (err) {
return cb(err)
}
cb(null, html)
}
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,18 @@
"vue-hot-reload-api": "^1.2.0"
},
"devDependencies": {
"babel-core": "^6.1.2",
"babel-plugin-transform-runtime": "^6.1.2",
"babel-preset-es2015": "^6.1.2",
"babel-runtime": "^5.8.0",
"coffee-script": "^1.10.0",
"jade": "^1.11.0",
"less": "^2.5.1",
"mocha": "^2.3.3",
"node-sass": "^3.3.3",
"pug": "^2.0.0-alpha6",
"stylus": "^0.52.4",
"vueify-insert-css": "^1.0.0",
"babel-core": "^6.1.2",
"babel-runtime": "^5.8.0",
"babel-preset-es2015": "^6.1.2",
"babel-plugin-transform-runtime": "^6.1.2",
"vue-hot-reload-api": "^1.2.0"
"vue-hot-reload-api": "^1.2.0",
"vueify-insert-css": "^1.0.0"
}
}
1 change: 1 addition & 0 deletions test/expects/pug.js
Original file line number Diff line number Diff line change
@@ -0,0 +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>"
11 changes: 11 additions & 0 deletions test/fixtures/pug.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template lang="pug">
//- Declaration
mixin list
ul
li foo
li bar
li baz
//- Use
+list
+list
</template>

0 comments on commit 20bd7f4

Please sign in to comment.