@static-pages/ejs-writer
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Static Pages / EJS Writer

Renders page data via EJS templates.

Uses the EJS package under the hood.

This package is part of the StaticPagesJs project, see:

Options

Option Type Default value Description
view string | (d: Data) => string main.ejs Template to render. If it's a function it gets evaluated on each render call.
viewsDir string | string[] views One or more directory path where the templates are found.
outDir string dist Directory where the rendered output is saved.
outFile string | (d: Data) => string see outFile section Path of the rendered output relative to outDir.
onOverwrite (d: string) => void console.warn(...) Callback function that gets executed when a file name collision occurs.
onInvalidPath (d: string) => void console.warn(...) Callback function that gets executed when a file name contains invalid characters.
ejsOptions ejs.Options {} Additional options to pass to the renderTemplate method.
showdownEnabled boolean true Register a markdown context function (this.markdown()); uses showdown.
showdownOptions showdown.ConverterOptions see showdownOptions section Custom options for the showdown markdown renderer.

outFile defaults

The default behaviour is to guess file path by a few possible properties of the data:

  • if data.url is defined, append .html and use that.
  • if data.header.path is defined, replace extension to .html and use that.
  • if nothing matches call the onInvalidPath handler with undefined file name.

showdownOptions defaults

This package uses a sligthly modified defaults compared to the official Showdown defaults:

{
	simpleLineBreaks: true,
	ghCompatibleHeaderId: true,
	customizedHeaderId: true,
	tables: true,
}

Package Sidebar

Install

npm i @static-pages/ejs-writer

Weekly Downloads

25

Version

1.0.3

License

MPL-2.0

Unpacked Size

27.7 kB

Total Files

8

Last publish

Collaborators

  • laszlo87
  • lionel87