@chriscalo/ejs-extra

A utility for rendering EJS templates with a few enhancements.

Usage no npm install needed!

<script type="module">
  import chriscaloEjsExtra from 'https://cdn.skypack.dev/@chriscalo/ejs-extra';
</script>

README

@chriscalo/ejs-extra

DEPRECATED. See ejs-plus

A utility for rendering EJS templates with a few enhancements.

Installation:

yarn add @chriscalo/ejs-extra
# or
npm install @chriscalo/ejs-extra

Usage:

const html = render("./foo.ejs", {
  req,
  res,
  list: [ 1, 2, 3 ],
});
<%
const util = require("./path/to/some/util.js");
%>
<%= req.originalUrl %>

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 a file rendering
  • create express view engine (docs)