/// import { RenderContext } from "../../context"; import { Environment } from "../../environment"; import { Loader, TemplateSource } from "../../loader"; import { Template } from "../../template"; import { ContextScope } from "../../types"; /** * Options for a file system template loader in the NodeJS runtime. */ export type NodeFileSystemLoaderOptions = { /** * The encoding to use when reading from a template file. All template * files in the search path are assumed to have the same encoding. Defaults * to utf8. */ encoding?: BufferEncoding; /** * A default file extension to apply if none is given. For example, to allow * template authors to write `{% include 'page' %}` instead of * `{% include 'page.liquid' %}`, set `fileExtension` to `'.liquid'`. * Defaults to the empty string. */ fileExtension?: string; }; /** * Options for a caching file system template loader in the NodeJS runtime. */ export type CachingNodeFileSystemLoaderOptions = NodeFileSystemLoaderOptions & { /** * When `true`, if a template has been cached, it will be reloaded * automatically if it has been modified since it was last loaded. * Defaults to `true` */ autoReload?: boolean; /** * The maximum number of templates to cache. Defaults to 300. */ cacheSize?: number; }; /** * A template loader that reads templates from a file system when deployed * to the NodeJS runtime. */ export declare class NodeFileSystemLoader extends Loader { readonly encoding: BufferEncoding; readonly fileExtension: string; readonly searchPath: string[]; /** * The `NodeFileSystemLoader` constructor. Create a new `NodeFileSystemLoader`. * * @param searchPath - A path, or array of paths, to search for templates. * @param options - Loader options. */ constructor(searchPath: string | string[], { encoding, fileExtension }?: NodeFileSystemLoaderOptions); getSource(name: string): Promise; getSourceSync(name: string): TemplateSource; /** * Append the default file extension if the given template name does * not have one. * @param name - A template file name relative to one of the paths in the * current search path. * @returns The argument name with the default file extension, if it did * not already have one. */ protected withFileExtension(name: string): string; /** * Find the path to the template file with the given name. * @param name - A template file name relative to one of the paths in the * current search path. * @returns The template file name joined with the first path in the * configured search path that is a file. * @throws {@link TemplateNotFoundError} * If a file with the given name can not be found. */ protected resolve(name: string): Promise; /** * A synchronous version of {@link resolve}. */ protected resolveSync(name: string): string; } /** * A template loader that caches templates read from a file system. */ export declare class CachingNodeFileSystemLoader extends Loader { #private; readonly autoReload: boolean; readonly cacheSize: number; readonly encoding: BufferEncoding; readonly fileExtension: string; readonly searchPath: string[]; /** * The `CachingNodeFileSystemLoader` constructor. * * @param searchPath - A path, or array of paths, to search for templates. * @param options - Loader options. */ constructor(searchPath: string | string[], { autoReload, cacheSize, encoding, fileExtension, }?: CachingNodeFileSystemLoaderOptions); /** * * @param templatePath - * @param mtime - * @returns */ static upToDate(templatePath: string, mtime: number): Promise; /** * * @param templatePath - * @param mtime - * @returns */ static upToDateSync(templatePath: string, mtime: number): boolean; getSource(name: string): Promise; getSourceSync(name: string): TemplateSource; load(name: string, environment: Environment, context?: RenderContext, globals?: ContextScope, loaderContext?: ContextScope): Promise