diff --git a/README.md b/README.md index 809c89e..db3c7b1 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ These are the preprocessors supported by vueify out of the box: - scss (via `node-sass`, use `sass` in [config section](#configuring-options)) - jade - pug +- ejs - coffee-script (use `coffee` in [config section](#configuring-options)) ## PostCSS diff --git a/lib/compilers/ejs.js b/lib/compilers/ejs.js new file mode 100644 index 0000000..ecae1ed --- /dev/null +++ b/lib/compilers/ejs.js @@ -0,0 +1,12 @@ +var ensureRequire = require('../ensure-require.js') + +module.exports = function (raw, cb, compiler) { + ensureRequire('ejs', 'ejs') + var ejs = require('ejs') + try { + var html = ejs.render(raw, compiler.options.ejs || {}) + } catch (err) { + return cb(err) + } + cb(null, html) +} diff --git a/lib/compilers/index.js b/lib/compilers/index.js index f7cbfa7..57040d2 100644 --- a/lib/compilers/index.js +++ b/lib/compilers/index.js @@ -7,5 +7,6 @@ module.exports = { scss: require('./sass'), stylus: require('./stylus'), jade: require('./jade'), - pug: require('./pug') + pug: require('./pug'), + ejs: require('./ejs') } diff --git a/package.json b/package.json index 1d8e9a6..7f9a199 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "chalk": "^1.1.1", "convert-source-map": "^1.2.0", "cssnano": "^3.3.2", + "ejs": "^2.5.2", "hash-sum": "^1.0.2", "lru-cache": "^4.0.0", "object-assign": "^4.0.1", diff --git a/test/fixtures/ejs-template-import.ejs b/test/fixtures/ejs-template-import.ejs new file mode 100644 index 0000000..c9dc2ee --- /dev/null +++ b/test/fixtures/ejs-template-import.ejs @@ -0,0 +1,3 @@ +