/** * Compile an EJS template string into a render function. * @template {Options} [O = Options] * @param {string} ejs * @param {O} [options] * @returns {(data?: unknown) => O extends {async: true} ? Promise : string} */ export function compile(ejs: string, options?: O): (data?: unknown) => O extends { async: true; } ? Promise : string; export type Options = { /** * Namespace for template data (default `'locals'`). */ localsName?: string | undefined; /** * Variables to access directly inside templates. */ locals?: string[] | undefined; /** * Value used as `this` in templates (default `null`). */ context?: unknown; /** * Custom escape function for `<%= ... %>` (defaults to XML-escaping). */ escape?: ((value: string) => string) | undefined; /** * Compile to an async function so `await` can be used (default `false`). */ async?: boolean | undefined; /** * Template file name, used to resolve includes. */ filename?: string | undefined; /** * Reader for include contents. */ read?: ((filename: string) => string) | undefined; /** * Include path resolver (defaults to identity on the include path). */ resolve?: ((parentPath: string | undefined, includePath: string) => string) | undefined; /** * Cache of compiled include bodies (default `{}`). */ cache?: Record | undefined; }; export type ResolvedOptions = Options & Required>;