1.0.3 • Published 2 years ago

@static-pages/ejs-writer v1.0.3

Weekly downloads
-
License
MPL-2.0
Repository
github
Last release
2 years ago

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

OptionTypeDefault valueDescription
viewstring \| (d: Data) => stringmain.ejsTemplate to render. If it's a function it gets evaluated on each render call.
viewsDirstring \| string[]viewsOne or more directory path where the templates are found.
outDirstringdistDirectory where the rendered output is saved.
outFilestring \| (d: Data) => stringsee outFile sectionPath of the rendered output relative to outDir.
onOverwrite(d: string) => voidconsole.warn(...)Callback function that gets executed when a file name collision occurs.
onInvalidPath(d: string) => voidconsole.warn(...)Callback function that gets executed when a file name contains invalid characters.
ejsOptionsejs.Options{}Additional options to pass to the renderTemplate method.
showdownEnabledbooleantrueRegister a markdown context function (this.markdown()); uses showdown.
showdownOptionsshowdown.ConverterOptionssee showdownOptions sectionCustom 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,
}