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 @@ +
+

hello

+
diff --git a/test/fixtures/ejs-template-import.vue b/test/fixtures/ejs-template-import.vue new file mode 100644 index 0000000..7f94c59 --- /dev/null +++ b/test/fixtures/ejs-template-import.vue @@ -0,0 +1 @@ + diff --git a/test/fixtures/ejs.vue b/test/fixtures/ejs.vue new file mode 100644 index 0000000..0f8bfdf --- /dev/null +++ b/test/fixtures/ejs.vue @@ -0,0 +1,5 @@ + diff --git a/test/test.js b/test/test.js index 69d3e4b..7458396 100644 --- a/test/test.js +++ b/test/test.js @@ -92,6 +92,17 @@ describe('vueify', () => { ) }) + test('ejs', window => { + var module = window.vueModule + assertRenderFn(module, + '
' + + '

This is the app

' + + '' + + '' + + '
' + ) + }) + test('scoped-css', window => { var module = window.vueModule var id = 'data-v-' + genId(require.resolve('./fixtures/scoped-css.vue')) @@ -123,6 +134,11 @@ describe('vueify', () => { assertRenderFn(module, '

hello

') }) + test('ejs-template-import', window => { + var module = window.vueModule + assertRenderFn(module, '

hello

') + }) + test('script-import', window => { var module = window.vueModule expect(module.data().msg).to.contain('Hello from Component A!') pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy