diff --git a/examples/eta/express.js b/examples/eta/express.js
new file mode 100644
index 0000000..eb8c762
--- /dev/null
+++ b/examples/eta/express.js
@@ -0,0 +1,43 @@
+// npm install express
+const path = require('node:path');
+const express = require('express');
+const cons = require('../../');
+
+// Example of declaring eta with custom options.
+const eta = new (require('eta').Eta)({
+ // Have to let Express handle the views directory instead.
+ views: '.',
+ varName: 'that',
+ autoFilter: true,
+ filterFunction(val) {
+ if (typeof val === 'string') {
+ return val.toUpperCase();
+ }
+ }
+});
+
+const app = express();
+
+cons.requires.eta = eta;
+app.engine('eta', cons.eta);
+app.set('view engine', 'eta');
+app.set('views', path.join(__dirname, './views'));
+
+const users = [];
+users.push({ name: 'tobi' }, { name: 'loki' }, { name: 'jane' });
+
+app.get('/', function (req, res) {
+ res.render('index', {
+ title: 'Consolidate.js'
+ });
+});
+
+app.get('/users', function (req, res) {
+ res.render('users', {
+ title: 'Users',
+ users
+ });
+});
+
+app.listen(3000);
+console.log('Express server listening on port 3000');
diff --git a/examples/eta/views/index.eta b/examples/eta/views/index.eta
new file mode 100644
index 0000000..14ec32a
--- /dev/null
+++ b/examples/eta/views/index.eta
@@ -0,0 +1,5 @@
+
<%= that.title %>
+Welcome to the <%= that.title %> demo. Click a link:
+
\ No newline at end of file
diff --git a/examples/eta/views/users.eta b/examples/eta/views/users.eta
new file mode 100644
index 0000000..0c9d9ca
--- /dev/null
+++ b/examples/eta/views/users.eta
@@ -0,0 +1,7 @@
+<%= that.title %>
+
+ <% that.users.forEach((user) => { %>
+ - <%= user.name %>
+ <% /* You can't see me */ %>
+ <% }); %>
+
\ No newline at end of file
diff --git a/lib/consolidate.js b/lib/consolidate.js
index c928767..9706d4c 100644
--- a/lib/consolidate.js
+++ b/lib/consolidate.js
@@ -750,6 +750,44 @@ exports.ejs.render = function (str, options, cb) {
});
};
+/**
+ * Eta support.
+ */
+
+exports.eta = function (path, options, cb) {
+ return promisify(cb, function (cb) {
+ try {
+ const engine =
+ requires.eta ||
+ (requires.eta = new (require('eta').Eta)({
+ views: '.'
+ }));
+ cb(null, engine.render(path, options));
+ } catch (err) {
+ cb(err);
+ }
+ });
+};
+
+/**
+ * Eta string support.
+ */
+
+exports.eta.render = function (str, options, cb) {
+ return promisify(cb, function (cb) {
+ try {
+ const engine =
+ requires.eta ||
+ (requires.eta = new (require('eta').Eta)({
+ views: '.'
+ }));
+ cb(null, engine.renderString(str, options));
+ } catch (err) {
+ cb(err);
+ }
+ });
+};
+
/**
* Eco support.
*/
diff --git a/package.json b/package.json
index cd94f47..b74e37d 100644
--- a/package.json
+++ b/package.json
@@ -27,6 +27,7 @@
"ejs": "^3.1.9",
"eslint": "8.42.0",
"eslint-config-xo-lass": "2",
+ "eta": "^3.1.1",
"fixpack": "^4.0.0",
"haml-coffee": "^1.14.1",
"hamlet": "^0.3.3",
diff --git a/test/consolidate.js b/test/consolidate.js
index f22571e..615d8f4 100644
--- a/test/consolidate.js
+++ b/test/consolidate.js
@@ -17,6 +17,7 @@ require('./shared/filters').test('liquid-node');
require('./shared/includes').test('liquid-node');
require('./shared').test('ejs');
+require('./shared').test('eta');
require('./shared').test('swig');
require('./shared').test('jazz');
require('./shared').test('jqtpl');
diff --git a/test/fixtures/eta/user.eta b/test/fixtures/eta/user.eta
new file mode 100644
index 0000000..c1bc24a
--- /dev/null
+++ b/test/fixtures/eta/user.eta
@@ -0,0 +1 @@
+<%= it.user.name %>
\ No newline at end of file