Options
All
  • Public
  • Public/Protected
  • All
Menu

Generates resources by making use of a template engine. The template folder structure will be kept. Folders will be interpreted as containers and files as documents. A FileIdentifierMapper will be used to generate identifiers that correspond to the relative structure.

A relative templateFolder is resolved relative to cwd, unless it's preceded by $PACKAGE_ROOT/, e.g. $PACKAGE_ROOT/foo/bar.

Hierarchy

  • TemplatedResourcesGenerator

Implements

Index

Constructors

constructor

Properties

Private Readonly factory

Private Readonly templateEngine

templateEngine: TemplateEngine<Dict<any>>

Private Readonly templateExtension

templateExtension: string

Private Readonly templateFolder

templateFolder: string

Methods

generate

Private generateMetadata

Private generateResource

  • generateResource(link: TemplateResourceLink, options: Dict<string>, metaLink?: TemplateResourceLink): Promise<Resource>
  • Generates a Resource object for the given ResourceLink. In the case of documents the corresponding template will be used. If a ResourceLink of metadata is provided the corresponding data will be added as metadata.

    Parameters

    • link: TemplateResourceLink
    • options: Dict<string>
    • Optional metaLink: TemplateResourceLink

    Returns Promise<Resource>

Private groupLinks

  • groupLinks(folderPath: string, mapper: FileIdentifierMapper): Promise<Record<string, { link: TemplateResourceLink; meta?: TemplateResourceLink }>>
  • Generates TemplateResourceLinks for each entry in the given folder and combines the results so resources and their metadata are grouped together.

    Parameters

    Returns Promise<Record<string, { link: TemplateResourceLink; meta?: TemplateResourceLink }>>

Private processFile

  • processFile(link: TemplateResourceLink, options: Dict<string>): Promise<Guarded<Readable>>

Private processFolder

Private toTemplateLink

  • Creates a TemplateResourceLink for the given filePath. The identifier will be based on the file path stripped from the template extension, but the filePath parameter will still point to the original file.

    Parameters

    Returns Promise<TemplateResourceLink>