Skip to content

Commit

Permalink
Drop ejs-mate (#157)
Browse files Browse the repository at this point in the history
ejs-mate has not been updated in 2 years time and v3.0.0 fails.
We do not have the bandwidth to keep supporting it.
  • Loading branch information
mcollina authored May 8, 2020
1 parent 7981c05 commit b84da48
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 229 deletions.
29 changes: 1 addition & 28 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const accessSync = require('fs').accessSync
const resolve = require('path').resolve
const join = require('path').join
const HLRU = require('hashlru')
const supportedEngines = ['ejs', 'nunjucks', 'pug', 'handlebars', 'marko', 'ejs-mate', 'mustache', 'art-template', 'twig']
const supportedEngines = ['ejs', 'nunjucks', 'pug', 'handlebars', 'marko', 'mustache', 'art-template', 'twig']

function fastifyView (fastify, opts, next) {
if (!opts.engine) {
Expand Down Expand Up @@ -44,7 +44,6 @@ function fastifyView (fastify, opts, next) {
const renders = {
marko: viewMarko,
ejs: withLayout(viewEjs),
'ejs-mate': viewEjsMate,
handlebars: withLayout(viewHandlebars),
mustache: viewMustache,
nunjucks: viewNunjucks,
Expand Down Expand Up @@ -239,32 +238,6 @@ function fastifyView (fastify, opts, next) {
})
}

function viewEjsMate (page, data) {
if (!page) {
this.send(new Error('Missing data'))
return
}

data = Object.assign({}, defaultCtx, data)
const confs = Object.assign({}, options)
if (!confs.settings) {
confs.settings = {}
}
// ejs-mate use views to find layouts
confs.settings.views = templatesDir
// setting locals to pass data by
confs.locals = Object.assign({}, confs.locals, data)
// append view extension
page = getPage(page, 'ejs')
engine(join(templatesDir, page), confs, (err, html) => {
if (err) return this.send(err)
if (options.useHtmlMinifier && (typeof options.useHtmlMinifier.minify === 'function')) {
html = options.useHtmlMinifier.minify(html, options.htmlMinifierOptions || {})
}
this.header('Content-Type', 'text/html; charset=' + charset).send(html)
})
}

function viewArtTemplate (page, data) {
if (!page) {
this.send(new Error('Missing page'))
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"art-template": "^4.13.2",
"cross-env": "^7.0.2",
"ejs": "^3.1.2",
"ejs-mate": "^2.0.0",
"express": "^4.17.1",
"fastify": "^3.0.0-rc.1",
"handlebars": "^4.7.6",
Expand Down
185 changes: 0 additions & 185 deletions test/test-ejs-mate.js

This file was deleted.

15 changes: 0 additions & 15 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,3 @@ test('register callback with handlebars engine should throw if layout file does
t.deepEqual('unable to access template "./templates/does-not-exist.hbs"', err.message)
})
})

test('register callback should throw if layout option is provided and engine is not handlebars or ejs', t => {
t.plan(2)
const fastify = Fastify()

fastify.register(require('../index'), {
engine: {
'ejs-mate': require('ejs-mate')
},
layout: './templates/layout.hbs'
}).ready(err => {
t.ok(err instanceof Error)
t.deepEqual('"layout" option only available for handlebars and ejs engine', err.message)
})
})

0 comments on commit b84da48

Please sign in to comment.