From 1c64dbf17edcaeefa10cccd168977ef5f2fb6727 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Tue, 3 May 2016 07:50:36 -0500 Subject: [PATCH] Add pug support Closes #79 --- README.md | 1 + lib/compilers/index.js | 3 ++- lib/compilers/pug.js | 15 +++++++++++++++ package.json | 13 +++++++------ test/expects/pug.js | 1 + test/fixtures/pug.vue | 11 +++++++++++ 6 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 lib/compilers/pug.js create mode 100644 test/expects/pug.js create mode 100644 test/fixtures/pug.vue diff --git a/README.md b/README.md index 0489cc5..5c48cdd 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,7 @@ These are the built-in preprocessors: - less - scss (via `node-sass`) - jade +- pug - coffee-script ## Autoprefix by Default diff --git a/lib/compilers/index.js b/lib/compilers/index.js index 62a66e2..f7cbfa7 100644 --- a/lib/compilers/index.js +++ b/lib/compilers/index.js @@ -6,5 +6,6 @@ module.exports = { sass: require('./sass'), scss: require('./sass'), stylus: require('./stylus'), - jade: require('./jade') + jade: require('./jade'), + pug: require('./pug') } diff --git a/lib/compilers/pug.js b/lib/compilers/pug.js new file mode 100644 index 0000000..a7e821c --- /dev/null +++ b/lib/compilers/pug.js @@ -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) +} diff --git a/package.json b/package.json index 29a8ab6..2afee6e 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/test/expects/pug.js b/test/expects/pug.js new file mode 100644 index 0000000..1ad9008 --- /dev/null +++ b/test/expects/pug.js @@ -0,0 +1 @@ +;(typeof module.exports === "function"? module.exports.options: module.exports).template = "" diff --git a/test/fixtures/pug.vue b/test/fixtures/pug.vue new file mode 100644 index 0000000..d1b7643 --- /dev/null +++ b/test/fixtures/pug.vue @@ -0,0 +1,11 @@ +