A utility for rendering EJS templates with enhancements.
Installation:
yarn add ejs-plus
# or
npm install ejs-plus
Usage:
const { render } = require("ejs-plus");
const html = render("./foo.ejs", {
foo: "bar",
list: [ 1, 2, 3 ],
});
<%
const util = require("./path/to/some/util.js");
%>
<%= foo %>
<% for (const i of list) { %>
<%= util.doThing(i) %>
<% } %>
Features:
- use
require()
in EJS files - a better
include()
function with support for absolute, relative, and module paths - helpful errors messages via
ejs-lint
TODO:
- async rendering
- separate functions for string and file rendering
- create express view engine (docs)