1.0.4 • Published 2 years ago

@static-pages/mustache-writer v1.0.4

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

Static Pages / Mustache Writer

Renders page data via Mustache templates.

Uses the Mustache package under the hood.

This package is part of the StaticPagesJs project, see:

Options

OptionTypeDefault valueDescription
viewstring \| (d: Data) => stringmain.mustacheTemplate 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.
showdownEnabledstring[][]Transform these variables to 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,
}