Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "file-handlers"

Index

Type aliases

CallbackFn

CallbackFn: (err: Error | null, str?: undefined | string) => void

Type declaration

    • (err: Error | null, str?: undefined | string): void
    • Parameters

      • err: Error | null
      • Optional str: undefined | string

      Returns void

Functions

handleCache

  • Get the template from a string or a file, either compiled on-the-fly or read from cache (if enabled), and cache the template if needed.

    If options.cache is true, this function reads the file from options.filename so it must be set prior to calling this function.

    Parameters

    Returns TemplateFunction

    Eta template function

includeFile

  • Get the template function.

    If options.cache is true, then the template is cached.

    This returns a template function and the config object with which that template function should be called.

    remarks

    It's important that this returns a config object with filename set. Otherwise, the included file would not be able to use relative paths

    Parameters

    • path: string

      path for the specified file (if relative, specify views on options)

    • options: EtaConfig

      compilation options

    Returns [TemplateFunction, EtaConfig]

loadFile

  • Reads a template, compiles it into a function, caches it if caching isn't disabled, returns the function

    Parameters

    • filePath: string

      Absolute path to template file

    • options: PartialConfigWithFilename

      Eta configuration overrides

    • Optional noCache: undefined | false | true

      Optionally, make Eta not cache the template

    Returns TemplateFunction

renderFile

tryHandleCache

  • Try calling handleCache with the given options and data and call the callback with the result. If an error occurs, call the callback with the error. Used by renderFile().

    Parameters

    Returns void | Promise<string>

Generated using TypeDoc