ejs-prerender

1.1.1 • Public • Published

ejs-prerender

Usage

This package is typically used as a devDependency. Install by running npm i -D ejs-prerender. It can be used as an npm script like the following:

"build:templates": "ejs-prerender",

and run manually using npx:

npx ejs-prerender

This package utilizes the debug library, so adding DEBUG=ejs-prerender:* to a .env file or the command path (DEBUG=ejs-prerender:* npx ejs-prerender) will enable logging of everything.

Recommended File Structure

The following file structure works out-of-the-box with no customized environment variables.

root
├ components/
│ └ head.ejs
└ pages/
  ├ about/
  │ └ index.ejs
  └ index.ejs

will render as

root
└ public/
  ├ about/
  │ └ index.html
  └ index.html

The components can be simply referenced inside EJS pages as seen below:

<!DOCTYPE html>
<html>
  <head>
    <%- include('head') -%>
  </head>
  <body><h1>INDEX</h1></body>
</html>

Configuration

Environment Variables

Option Environment Variable Type Default Description
baseDir PEJS_BASE_DIR String current working directory Base directory to reference for other relative paths
outputDir PEJS_BUILD_OUTPUT_DIR String 'public' Where the completed pages get written
componentsDir PEJS_BUILD_COMPONENTS_DIR String 'components' Where components live
pagesDir PEJS_BUILD_PAGES_DIR String 'pages' Where pages live
pageExtension PEJS_BUILD_PAGES_EXT String 'ejs' File extension of pages

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.1
    1
    • latest

Version History

Package Sidebar

Install

npm i ejs-prerender

Weekly Downloads

1

Version

1.1.1

License

MIT

Unpacked Size

10 kB

Total Files

20

Last publish

Collaborators

  • wilderbeest